import com.mysql.jdbc.Driver; import java.sql.Connection; import java.sql.
DriverManager; import java.sql.SQLException; import java.sql.Statement; public
class TestJDBCConnection { public static void main(String[] args) { // First step : Register driver
Statement statement=null; Connection connection=null; try { DriverManager.
registerDriver(new com.mysql.jdbc.Driver()); // Step two : Create connection String url=
"jdbc:mysql://127.0.0.1:3306/mobilemallsystem"; String user="root"; String
password="123456"; connection= DriverManager.getConnection(url,user, password);
// System.out.println(" Database connection object "+connection); // Step 3 : Get database operation object (SQL Statement execution object )
statement= connection.createStatement(); // Step 4 : implement SQL sentence String sql="insert into
usermessage(uname,upassword) values('666','666')"; statement.executeUpdate(sql);
// Step 5 : Process query result set // Step 6 : Release resources } catch (SQLException throwables) { throwables.
printStackTrace(); }finally { if(statement!=null){ try { statement.close(); }
catch (SQLException throwables) { throwables.printStackTrace(); } } if(
connection!=null){ try { connection.close(); } catch (SQLException throwables) {
throwables.printStackTrace(); } } } } }

Technology