Basic JDBC learning and basic jdbc
1. Concept: java Database Connection Technology
2. JDBC:Is a specification that provides Interfaces(Interface-Oriented Programming)
3. jdbc api:Provides interfaces and classes called by programmers, Integrated in the java. SQL and javax. SQL packages. For example:DriverManager class (managing different JDBC drivers), Connerction interface, Statement interface, and ResultSet Interface
4. jdbc api main functions:Establish connections with databases, execute SQL statements, and process results
5. Three interfaces:
<1> Connerction interface:Connects to the database and transmits data.
<2> Statement interface: this interface is generated by Connection and is responsible for executing SQL statements.
<3> ResultSet interface: maintains the query results generated after Statement execution.
6. JDBC steps:
1. Load the JDBC driver
Class. forName (JDBC Driver Class );
2. Establish a connection with the database
Connection conn = Drivermanager. getConnection (URL, database username, password );
3. Send SQL statements and get the returned results
Statement stmt = conn. creteStatement ();
ResultSet rs = stmt = executeQuery ("SELECT a FROM Table1 ");
Iv. handling results
While (rs. next ()){
Int x rs. getInt ("");
}
5. release resources
Rs. close ();
Stmt. close ();
Conn. close ();
Template