Advertisement
Guest User

Untitled

a guest
Dec 4th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. package SQL_Project;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.PreparedStatement;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8. import java.sql.Statement;
  9.  
  10.  
  11. public class Admin {
  12. public static java.util.Scanner scanner = new java.util.Scanner(System.in);
  13. private String url = "jdbc:postgresql://localhost:5432/postgres"; // LOCAL
  14. //private String url="jdbc:postgresql://172.24.2.6:5432/gcurato16"; // ECOLE
  15. private Connection conn=null;
  16.  
  17.  
  18. public Admin() {
  19.  
  20.  
  21. // test driver
  22. try {
  23. Class.forName("org.postgresql.Driver");
  24.  
  25. } catch (ClassNotFoundException e) {
  26. System.out.println("Driver PostgreSQL manquant !");
  27. System.exit(1);
  28. }
  29.  
  30.  
  31. // test connection
  32. try {
  33. conn = DriverManager.getConnection(url, "gcurato16", "(9YAVaP@");
  34.  
  35. } catch (SQLException e) {
  36. System.out.println("Impossible de joindre le serveur");
  37. System.exit(1);
  38. }
  39.  
  40.  
  41.  
  42. }
  43.  
  44.  
  45. // fermer connection
  46. public void close() {
  47. try {
  48. conn.close();
  49. } catch (SQLException e) {
  50. e.printStackTrace();
  51. }
  52. }
  53.  
  54.  
  55. public static void main(String[] args) {
  56. }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement