Advertisement
Guest User

Untitled

a guest
Nov 12th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  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 DATABASE;
  7.  
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.SQLException;
  11.  
  12. /**
  13.  *
  14.  * @author birosandras
  15.  */
  16. public class Database {
  17.    
  18.     private static final String URL = "jdbc:mysql://localhost:3306/login?autoReconnect=true&useSSL=false";
  19.     private static final String USERNAME = "root";
  20.     private String PASSWORD = "";
  21.  
  22.     public Database() {
  23.  
  24.     }
  25.  
  26.     public Connection getConnection(){
  27.         Connection con = null;
  28.  
  29.         try {
  30.             Class.forName("com.mysql.jdbc.Driver");
  31.             con = DriverManager.getConnection(URL, USERNAME, PASSWORD);
  32.         } catch (ClassNotFoundException|SQLException e1) {
  33.             throw new RuntimeException(e1);
  34.         }
  35.         return con;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement