Advertisement
Guest User

Untitled

a guest
May 24th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. package dataBase;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5.  
  6. public class DBConnection {
  7.  
  8. public static Connection connection;
  9.  
  10. public static Connection getConnection()
  11. {
  12.  
  13. String db_url = "jdbc:mysql://localhost/room_booking?useSSL=false";//LOGIN is the database.
  14. String DBName = "root";//username to connect to mysql
  15. String DBPassword = "root";//password to connect to mysql
  16.  
  17.  
  18. try {
  19. Class.forName("com.mysql.jdbc.Driver").newInstance();
  20.  
  21. connection= DriverManager.getConnection(db_url, DBName, DBPassword);
  22.  
  23.  
  24. } catch (Exception e) {
  25. e.printStackTrace();
  26. }
  27.  
  28.  
  29. return connection;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement