Advertisement
Guest User

Untitled

a guest
Aug 6th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. private static Connection connection = null;
  2.  
  3.  
  4. public static Connection getConnection()
  5.  
  6.  
  7. {
  8. try{
  9. if(connection == null){
  10. Class.forName("com.mysql.jdbc.Driver");
  11. Connection con=DriverManager.getConnection(
  12. "jdbc:mysql://localhost/demo","root","");
  13. connection = con;
  14. }
  15.  
  16. }catch(Exception e)
  17. {
  18. System.out.println(e);
  19. }
  20. return connection;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement