Statement: The material used in this column is written by the VIP students of the Kay Academy, who has the right to be anonymous and has the final right to interpret the article; The Edith Academy is designed to promote students to learn from each other on the basis of public notes.
Jdbc:
JDBC full name is Java DataBase Connection
The JDBC API is both an interface and why it is an interface:
1. Unified operation
2. Transferring responsibility to the database developer
How to add a jar package:
Eclipse General Engineering Add:
1. Locate the appropriate database jar package
2. Copy the jar package directly to the project catalog
3. Adding to the compilation environment
This method is to remove the package, must be lifted to delete
Eclipse maven Maven Project add
1. First enter the Central warehouse www.mvnrepository.com
2. Then search for MySQL
Then select the version you want to download and add the dependent copy to eclipse
Oracle jar Package Download:
can also be found directly in Oracle's installation directory
The JDBC interface describes: (these interfaces are all stored under the java.sql package)
The DriverManager driver Administrator is used to create the Connectionconnection database Connection object statement SQL execution Object PreparedStatement ResultSet Query result set resultsetmetadata query table structure callablestatement stored procedure Call
What is the driver, the driver is the implementation of the JDBC interface operation class Mysql JDBC API jar
Java Connection Database steps: 1. Find the jar package >> add to the project first
If it's maven, just set the dependency right.
2. Start the database to ensure that the database can be connected in network mode
3. Load driver (some database driver packages can be loaded automatically) Class.forName ("Com.mysql,jdbc. Driver ");
Use class to load classes so that static members are initialized
Loading the driver class, its static block executes, and the static block is immediately registered and driven to the driver administrator class
New Com.mysql.jdbc.Driver (); New can also initialize the load class
The properties inside the Com.mysql.jdbc.Driver.class call can also initialize the load class.
Learn to see if the database jar has meta-inf/service this folder, which says it automatically loads
4. Create a Connection object using the DRIVERMANAGR administrator
It is generally filled with three data, the following three:
Drivermanager.getconnection ("", "", "");
MySQL URL Many ways: 1.jdbc:mysql:///mysql default local and default port 3306
2.jdbc:mysql://127.0.0.1:3306/mysql This is the definition of the address port
1. URL Connect What database server address server port database name other settings
2. User name 3. password
This is the complete syntax for the Java connection database.
-java-jdbc Getting Started