Packageutil;ImportJava.sql.*;/*** JDBC Tool class*/Final Public classJdbcutil {Private StaticString user = "root";//Database user name Private StaticString password = "";//Database Login Password Private StaticString url = "Jdbc:mysql://127.0.0.1:3306/db_chat?useunicode=true&characterencoding=utf8";//Connect to database address Static { Try{class.forname ("Com.mysql.jdbc.Driver");//Load Driver}Catch(ClassNotFoundException e) {e.printstacktrace (); } } /*** Close Database connection*/ Public Static voidClose (ResultSet rs, Statement stmt, Connection conn) {Try { if(rs! =NULL) Rs.close (); } Catch(SQLException e) {e.printstacktrace (); } finally { Try { if(stmt! =NULL) Stmt.close (); } Catch(SQLException e) {e.printstacktrace (); } finally { Try { if(Conn! =NULL) Conn.close (); } Catch(SQLException e) {e.printstacktrace (); } } } } /*** Get database connection*/ Public StaticConnection getconnection () {Connection conn=NULL; Try { //connecting to a databaseconn =drivermanager.getconnection (Url,user,password); } Catch(SQLException e) {e.printstacktrace (); } returnConn; }}