Click to enter _ more _java thousand ask
1. What are the common Java Runtime exceptions
Understanding non-runtime exceptions look here: What is an exception in Java
Common run-time exceptions look here: What are common run-time exceptions
The common exception we call is the exception in the JDK or other commonly used third-party jar, with high frequency anomalies. Common non-runtime exceptions (that is, check exceptions, checked exception) include:
- Manipulating Database Exceptions: SQLException
- Input/Output exception: IOException
- File not found exception: FileNotFoundException
- Reflection Operation Exception: Reflectiveoperationexception
-
Class not found exception: ClassNotFoundException
-
Method not found exception: Nosuchmethodexception
- Field not found exception: Nosuchfieldexception
- Illegal access exception: Illegalaccessexception
- Instantiation Exception: Instantiationexception
-
Cloning exceptions are not supported: clonenotsupportedexception
-
Aborted exception: Interruptedexception
2. What happens when these exceptions are thrown
How to throw an exception see here: How Java throws an exception
1.java.lang.sqlexception
The exception is interpreted as: SQL exception.
There are many types of SQL statement exceptions, usually SQL statements, database execution errors, and common performance:
- Invalid column name is invalid
- Table or view does not exist tables or views do not exist
- Cannot insert null into () cannot insert a null value
- Missing an expression
- SQL command does not end correctly
It is necessary to consider the overall operation of the database and to avoid the exception as much as possible.
2.java.lang.ioexception
The exception is interpreted as an input/output exception.
There are also a number of exceptions (with many subclasses), especially for file operations, and Android development. Common manifestations are:
- The FileNotFoundException file cannot be found.
- Invalidpropertiesformatexception the input content does not conform to the correct XML document type for the attribute set.
3.java.lang.filenotfoundexception
The exception is interpreted as: there is no exception to the file. The exception inherits from IOException.
This exception is usually caused by an error in the file path or file name when getting the file.
4.java.lang.reflectiveoperationexception
The exception is interpreted as a reflection operation-related exception.
Because of the particularity of reflection, classes, methods, and properties all use string as the name of the operation, for such exceptions must be very careful.
See what reflection looks here: What is reflection in Java
5.java.lang.classnotfoundexception
The exception is interpreted as: The specified class does not exist. The exception inherits from Reflectiveoperationexception.
This exception is usually thrown when using reflection, or when the server introduces a jar package.
When using reflection, the exception is caused by an error in the package, class name when getting class based on the class name (string).
6.java.lang.nosuchmethodexception
The exception is interpreted as: The specified method does not exist. The exception inherits from Reflectiveoperationexception.
This exception is usually thrown when using reflection.
When using reflection, the method name (string) is used when calling methods, which causes the exception to be incorrect.
7.java.lang.nosuchfieldexception
The exception is interpreted as: The specified field does not exist. The exception inherits from Reflectiveoperationexception.
This exception is usually thrown when using reflection.
When using reflection, the exception is caused by incorrect field names when you get and manipulate fields based on field names (strings).
8.java.lang.illegalaccessexception
The exception is interpreted as: no access rights.
This exception occurs when the application is calling a class, but the current method does not have access to the class.
The most common place is when the private method/property is called with reflection, and the private method/property is shared with public.
Want to know public and privite see here: Public, privite, protected what is the difference
9.java.lang.instantiationexception
The exception is interpreted as: instantiating an exception. The exception inherits from Reflectiveoperationexception.
This exception is thrown when an attempt is made to create an instance of a class through the newinstance () method, which is an abstract class or interface.
10.java.lang.clonenotsupportedexception
The exception is interpreted as: Cloning exceptions are not supported. The exception inherits from Reflectiveoperationexception.
When the Cloneable interface is not implemented or the Clone method is not supported, the exception is thrown by calling its clone () method.
11.java.lang.interruptedexception
The exception is interpreted as: aborted exception.
This exception is thrown when a thread is in a long wait, hibernate, or other paused state while another thread terminates the thread through the interrupt method of the thread.
Java thousand ask _04 exception handling (007) _ Common Java Exceptions (non-runtime)