Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. public class DBConnection {
  4.  
  5. protected static Connection initializeDB() throws SQLException, ClassNotFoundException {
  6.  
  7. String dbDriver = "com.mysql.cj.jdbc.Driver";
  8. String dbUrl = "jdbc:mysql://localhost:3306/demo1";
  9. String username = " ";
  10. String password = " ";
  11.  
  12. Class.forName(dbDriver);
  13.  
  14. Connection con = DriverManager.getConnection(dbUrl,username,password);
  15.  
  16. return con;
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement