Home> Java> javaTutorial> body text

What is invocationtargetexception?

(*-*)浩
Release: 2019-07-27 10:49:39
Original
43462 people have browsed it

The JAVA reflection mechanism is that in the running state, for any entity class, all properties and methods of this class can be known; for any object, any of its methods and properties can be called; this dynamic acquisition of information and The function of dynamically calling object methods is called the reflection mechanism of the Java language.

What is invocationtargetexception?

The Java reflection mechanism refers to the fact that in the running state of a Java program, for any class, all properties and methods of this class can be obtained; for a given An object can call any of its properties and methods. This method of dynamically obtaining the content of a class and dynamically calling objects is called reflection mechanism. (Recommended learning:Java Video Tutorial)

Java's reflection mechanism allows programmers to obtain class-related information in more diverse and flexible ways when the class is unknown. The corresponding method is a mechanism for Java to increase its flexibility and dynamics.

Invocation targetexception is a reflection exception.

Usually the InvocationTargetException thrown is NullPointerException

View the specific method of the exception:

Put the mouse in the catch Exception ex, check the specific exception information thrown in the target.

Solution:

If the exception in the target is that a certain class cannot be found, check the error returned in sql. Check whether the fields in the class are consistent with the fields in the database. If they are inconsistent, modify them. The modification method is as follows:

If any of the fields you are looking for is defined as an enumeration type, escape it. For example,

SELECT ID, pro_OtherProductTypeID as proOtherProductTypeID, ExchangeType as exchangeType, ObjectID as objectID, name, RequireNubs as requireNubs, Repertory as repertory, CASE State WHEN 1 THEN 'NORMAL' WHEN 2 THEN 'RECYCLE' WHEN 127 THEN 'DELETED' END as 'State' from XXX
Copy after login

Among them, state has been defined as an enumeration in the project. You can use the case ..when ...then ...end method to escape in SQL and convert it into the corresponding value in the enumeration. Values that are not in the enumeration do not need to be converted.义

For more Java-related technical articles, please visit theJava Development Tutorialcolumn to learn!

The above is the detailed content of What is invocationtargetexception?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!