Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package fr.univ_amu.iut;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. /**
  8. * Created by b16008414 on 26/09/17.
  9. */
  10. public class ConnexionUnique {
  11. private Connection connection;
  12. private static ConnexionUnique instance = null;
  13.  
  14. private static final String CONNECT_URL = "jdbc:mysql://mysql-joebertin.alwaysdata.net:3306/joebertin_mydata";
  15. private static final String LOGIN = "joebertin";
  16. private static final String PASSWORD = "123456";
  17.  
  18. private ConnexionUnique() {
  19. try {
  20. connection = DriverManager.getConnection(CONNECT_URL,LOGIN,PASSWORD);
  21. } catch (SQLException e) {
  22. e.printStackTrace();
  23. }
  24. }
  25.  
  26. public Connection getConnection() {
  27. return connection;
  28. }
  29.  
  30. public static ConnexionUnique getInstance() {
  31. if(instance == null)
  32. instance = new ConnexionUnique();
  33. return instance;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement