1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
String driver = "com.oracle.jdbc.Driver";
String url = "http://127.0.0.1:8080/apex/f?p=4500:1003:164054685536745::NO:::";
import oracle.jdbc.driver.OracleDriver.*;
import java.sql.*;
class Base {
String login = "system";
String password = "smi2011";
Connection connection = null;
try{
Class.forName("com.oracle.jdbc.Driver");
connection = DriverManager.getConnection("http://127.0.0.1:8080/apex/f?p=4500:1003:164054685536745::NO:::,system,smi2011");
//travail avec les données
}
catch(ClassNotFoundException cnfe){
System.out.println("Driver introuvable : ");
cnfe.printStackTrace();
}
catch(SQLException sqle){
System.out.println("Erreur SQL : ");
//Cf. Comment gérer les erreurs ?
}
catch(Exception e){
System.out.println("Autre erreur : ");
e.printStackTrace();
}
finally
{
if(connection!=null){try{connection.close()}catch(Exception e){e.printStackTrace();}}
//etc.
}
} |
Partager