Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package SQL_Project;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class Admin {
- public static java.util.Scanner scanner = new java.util.Scanner(System.in);
- private String url = "jdbc:postgresql://localhost:5432/postgres"; // LOCAL
- //private String url="jdbc:postgresql://172.24.2.6:5432/gcurato16"; // ECOLE
- private Connection conn=null;
- public Admin() {
- // test driver
- try {
- Class.forName("org.postgresql.Driver");
- } catch (ClassNotFoundException e) {
- System.out.println("Driver PostgreSQL manquant !");
- System.exit(1);
- }
- // test connection
- try {
- conn = DriverManager.getConnection(url, "gcurato16", "(9YAVaP@");
- } catch (SQLException e) {
- System.out.println("Impossible de joindre le serveur");
- System.exit(1);
- }
- }
- // fermer connection
- public void close() {
- try {
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public static void main(String[] args) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement