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 34 35
|
/**
* @param args
* @throws ClassNotFoundException
* @throws IllegalAccessException
* @throws InstantiationException
* @throws SQLException
*/
public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
// TODO Raccord de méthode auto-généré
boolean bool = true;
Class.forName("org.hsqldb.jdbcDriver").newInstance();
Connection connexion = DriverManager.getConnection("jdbc:hsqldb:mem:database","sa","");
bool=connexion.isClosed();
System.out.println(bool);
Statement statement = connexion.createStatement();
statement.executeUpdate("CREATE TABLE test(colonne1 INT,colonne2 INT)");
statement.executeUpdate("INSERT INTO test VALUES (10,12)");
statement.executeQuery("SHUTDOWN");
statement.close();
Class.forName("org.hsqldb.jdbcDriver").newInstance();
Connection connexion2 = DriverManager.getConnection("jdbc:hsqldb:mem:database","sa","");
Statement statement2 = connexion2.createStatement();
ResultSet resultat = statement2.executeQuery("SELECT * FROM test ");
while(resultat.next()){
System.out.println(resultat.getDouble("colonne1"));
}
statement.close();
}
} |
Partager