derby -> apache
System.setProperty("derby.system.home", "dbname.db");
Connection conn = DriverManager.getConnection("jdbc:derby:test_db;create=true");
try {
Statement s = conn.createStatement();
s.execute("CREATE TABLE data (id INT, text VARCHAR(100), PRIMARY KEY (id))");
s.execute("INSERT INTO data VALUES (1, 'Hallo')");
s.execute("INSERT INTO data VALUES (2, 'Blub')");
ResultSet rs = s.exeucteQuery("SELECT text FROM data WHERE id=1");
while (rs.next()) {
String text = rs.getString("text");
System.out.println(text);
}
} finally {
conn.close();
}
Keine Kommentare:
Kommentar veröffentlichen