Advertisement
Guest User

blblblbblbl

a guest
Oct 2nd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. public class ConnexionUnique {
  2.  
  3. private static final String CONNECT_URL = "jdbc:mysql://mysql-perssam.alwaysdata.net:3306/perssam_tpjdbc";
  4. private static final String LOGIN = "perssam";
  5. private static final String PASSWORD = "billoute04";
  6.  
  7. private static ConnexionUnique instance;
  8.  
  9. private Connection connection;
  10.  
  11.  
  12.  
  13. private ConnexionUnique(){
  14. try {
  15. this.connection = DriverManager.getConnection(CONNECT_URL, LOGIN, PASSWORD);
  16. } catch (SQLException e) {
  17. e.printStackTrace();
  18. }
  19. }
  20.  
  21.  
  22. public Connection getConnection(){
  23. return connection;
  24. }
  25.  
  26.  
  27. public static ConnexionUnique getInstance(){
  28. if(instance == null){
  29. instance = new ConnexionUnique();
  30. }
  31. return instance;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement