Import Java. SQL. *; <br/> // The tool class is not inherited. Therefore, final cannot be inherited, static <SPAN class = 'wp _ keywordlink '> Code </span> blocks are executed only once <br/> Public final class jdbcutils {</P> <p>/Private Static protection, PRIVATE: <br/> Private Static string url = "JDBC. mySQL: // locallhost: 3306/jdbc "; <br/> Private Static string user =" root "; <br/> Private Static string passworld =" 123 "; </P> <p> // you cannot call private to construct an instance. If you want :??? Singleton + static public <br/> private jdbcutils () {<br/>}</P> <p> static {<br/> try {<br/> class. forname ("com. mySQL. JDBC. driver "); <br/>} catch (classnotfoundexception e) {<br/> throw new exceptionininitializererror (E ); <br/>}</P> <p> Public static connection getconnection () throws sqlexception {<br/> return drivermanager. getconnection (URL, user, passworld); <br/>}< br/> // release <br/> Public static void free (Resultset RS, statement St, connection conn) {<br/> try {<br/> If (RS! = NULL) {<br/> Rs. close (); <br/>}} catch (sqlexception e) {<br/> E. printstacktrace (); <br/>}finally {<br/> try {<br/> If (st! = NULL) <br/> St. close (); <br/>}catch (sqlexception e) {<br/> E. printstacktrace (); <br/>}</P> <p> finally {<br/> If (Conn! = NULL) <br/> try {<br/> Conn. close (); <br/>}catch (sqlexception e) {<br/> E. printstacktrace (); <br/>}</P> <p >}< br/>