JDBC steps

jdbc is a kind of JAVA API for special users to execute SQL. It is a set of APIs to access the database. By loading the driver provided by the database manufacturer, it can establish a link with the database, and has no platform to access the database. jdbc6 step:
1. Register the driver Class.forname (driver package) Through reflection, let the virtual machine dynamically find, load the specified class (provided that it is not loaded) and report an error class not found exception
2. Create links for unified use
Connection  c= DriverManager.getConnection(url,uname,upasss)
3. Create SQL statement object to execute SQL statement
Statement s=c.createStatement();
4, The SQL statement object executes the Sql statement and returns the result ResultSet
s.executeQuery/executeUpdate
5. Process results according to demand
Handle it casually, return the result set if the query is done, delete the added words
6, Close the link, the database link needs to consume system resources, and closes when it is not needed, forming a good habit, the correct order is from bottom to top, first the result set, then the SQL statement object, and finally the link
re.close();
s.close();
c.close();

Guess you like

Origin www.cnblogs.com/Vinlen/p/12749951.html