Advertisement
joseleonweb

Untitled

May 12th, 2021
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. Connection conn = null;
  2. try {
  3.     // db parameters
  4.     String url       = "jdbc:mysql://localhost:3306/mysqljdbc";
  5.     String user      = "root";
  6.     String password  = "secret";
  7.    
  8.     // create a connection to the database
  9.     conn = DriverManager.getConnection(url, user, password);
  10.     // more processing here
  11.     // ... 
  12. } catch(SQLException e) {
  13.    System.out.println(e.getMessage());
  14. } finally {
  15.     try{
  16.            if(conn ! null)
  17.              conn.close()
  18.     }catch(SQLException ex){
  19.            System.out.println(ex.getMessage())
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement