SHARE
TWEET

Untitled

a guest Jun 8th, 2017 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3.  
  4. public class test {
  5.     public static void main(String[] args) {
  6.         Connection con = null;
  7.  
  8.         try {
  9. Class.forName("com.mysql.jdbc.Driver");
  10.             con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "username", "password");
  11.  
  12.             // Do shit
  13.         } catch(Exception e) {
  14.             e.printStackTrace();   
  15.         } finally {
  16.             if(con != null) {
  17.                 try {
  18.                     con.close();
  19.                 } catch(Exception e) {
  20.                     e.printStackTrace();
  21.                 }
  22.             }
  23.         }
  24.     }
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top