JDBC Principle:
Add: Load Driver
Chain: Creating a connection
Pre: Create precompilation
Execute SQL statement (query requires processing result level)
Release: Close link;
Some interfaces are defined in DBC:
1. Drive Management:
DriverManager
2. Connection interface
Connection
DatabaseMetaData
3. Statement Object interface
Statement
PreparedStatement
CallableStatement
4. Result set interface
ResultSet
ResultSetMetaData
JDBC only defines interfaces, which are the responsibility of each database vendor.
Programmers only need to invoke the interface when using, the actual call is the implementation part of the underlying database vendor.
What is an exception in Java:
An abnormal condition that occurs during the operation of the program ; This behavior is called an exception.
The top-level parent class for Throwable is divided into Error and Exception exceptions
Error , which cannot be processed once it occurs ( such as a memory overflow ); and for Exception can usually be processed ;
Difference between throws and throw
Throw: Produces an exception object, positioned in the method, followed by an exception object, equivalent to the effect of return
Throws: Indicates that the exception method is thrown out of () {}, followed by multiple exceptions
Simply explain the polymorphism in the following Java:
The role of polymorphism: to eliminate the coupling relationship between types. (Coupling relationship refers to the relationship between two things if there is an interaction and interaction, then the relationship is called "coupling relationship")
There are two kinds of polymorphism: 1) Compile-time polymorphism for multiple methods with the same name, if at compile time it is possible to determine which of the methods in the same name is executed, then it is called compile-time polymorphism. 2) Runtime polymorphism If you cannot determine at compile time, you can only determine which of the multiple methods with the same name is run-time polymorphism
Three necessary conditions for polymorphic existence one, to have inheritance; second, to have the override; the parent class refers to the subclass object.
Briefly describe the JDBC Principle + what exceptions are in Java + throws and throw differences + simple explanations for the following polymorphism in Java