Advertisement
esspressoh

Untitled

Feb 13th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. package fr.ocr.sql;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class HsqldbConnection {
  8. // URL de connexion
  9. private String url = "jdbc:hsqldb:file:hsqldb/database/VEHICULE";
  10. // Nom du user
  11. private String user = "SA";
  12. // Mot de passe de l'utilisateur
  13. private String passwd = "";
  14. // Objet Connection
  15. private static Connection connect;
  16. private static HsqldbConnection instance = new HsqldbConnection();
  17.  
  18. // Constructeur priv�
  19. private HsqldbConnection() {
  20. try {
  21. connect = DriverManager.getConnection(url, user, passwd);
  22.  
  23.  
  24. } catch (SQLException e) {
  25. e.printStackTrace();
  26. }
  27. }
  28.  
  29. // M�thode d'acc�s au singleton
  30. public static Connection getInstance() {
  31. if (connect == null)
  32. instance = new HsqldbConnection();
  33.  
  34. return connect;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement