daily pastebin goal
54%
SHARE
TWEET

Untitled

a guest Mar 20th, 2017 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package pkgfinal;
  7.  
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.SQLException;
  11. import javax.swing.JOptionPane;
  12.  
  13. /**
  14.  *
  15.  * @author administrator
  16.  */
  17. public final class DB {
  18.     public static final String DB_URL = "jdbc:mysql://localhost:3306/jamdb";
  19.     public static final String DB_USERNAME = "root";
  20.     public static final String DB_PASSWORD = "";
  21.    
  22.     public static final Connection getConnection() {
  23.         Connection conn = null;
  24.         try {
  25.             Class.forName("com.mysql.jdbc.Driver").newInstance();
  26.             conn = (com.mysql.jdbc.Connection) DriverManager.getConnection(DB.DB_URL, DB.DB_USERNAME, DB.DB_PASSWORD);
  27.         } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | SQLException ex) {
  28.             JOptionPane.showMessageDialog(null, ex.getMessage());
  29.         }
  30.         return conn;
  31.     }
  32. }
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