1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public class Exercice5 {
static Connection con;
public static Connection getConnection() {
try {
Class.forName("oracle.jdbc.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@oracle1:1521:orcl", "ora05", "ps3");
} catch (ClassNotFoundException cnfex) {
System.err.println("Échec du chargement du pilote JDBC/ODBC.");
cnfex.printStackTrace();
System.exit(1);
} catch (SQLException sqlex) {
System.err.println("Connexion impossible");
sqlex.printStackTrace();
System.exit(1);
}
return con;
} |