Advertisement
Guest User

Untitled

a guest
Feb 19th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public class DBConnection {
  2.  
  3. private Connection connection;
  4. private static DBConnection dBConnection;
  5.  
  6. public DBConnection() throws ClassNotFoundException, SQLException {
  7. Class.forName("com.mysql.jdbc.Driver");
  8. connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/db", "root", "mysql");
  9. }
  10.  
  11. public static DBConnection getDBConnection() throws ClassNotFoundException, SQLException {
  12. if (dBConnection == null) {
  13. dBConnection = new DBConnection();
  14. }
  15. return dBConnection;
  16. }
  17.  
  18. public Connection getConnection() {
  19. return connection;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement