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 33
| try {
Connection conn = null;
String dbURL = "jdbc:derby:." + "chemin de la base/" + "nom de la base;user=APP";
sc = new org.apache.derby.drda.NetworkServerControl(InetA conn = null;
Statement stmt = null;
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
conn = DriverManager.getConnection(dbURL);
stmt = conn.createStatement();
String s = "Ma requete SQL";
ResultSet results = stmt.executeQuery(s);
while (results.next()) {
//traittement a faire
}
results.close();
stmt.close();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(JavaApplication1.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(JavaApplication1.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(JavaApplication1.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(JavaApplication1.class.getName()).log(Level.SEVERE, null, ex);
} finally {
} |