Guest User

Untitled

a guest
Jul 15th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. public class Singleton {
  2. private static final Singleton instance = new Singleton();
  3.  
  4. // Private constructor prevents instantiation from other classes
  5. private Singleton() {
  6.  
  7.  
  8.  
  9. String url = "jdbc:mysql:///test"; // baza de date "test"
  10. String user = "root";
  11. String password = "101010";
  12. Class.forName ("com.mysql.jdbc.Driver").newInstance ();
  13. conn = DriverManager.getConnection (url, user, password);
  14. System.out.println ("Database connection established");
  15.  
  16. }
  17.  
  18. public static Singleton getInstance() {
  19. return instance;
  20. }
  21. }
Add Comment
Please, Sign In to add comment