Простая вставка в JDBC
Листинг 12.5. Простая вставка в JDBC
Statement s - null: try {
s = c.createStatement():
} catch (SQLException se) {
System.out.printlnC'We got an exception while creating a statement:" +
"that probably means we're no longer connected."):
se.printStackTrace();
System.exlt(1):
}
int m = 0;
try {
m = s.executeUpdateC1 INSERT INTO books VALUES " +
"(41472. 'Practical PostgreSGl'. 1212. 4)"): >
} catch (SQLException se) {
System.out.println("We got an exception while executing our query:" +
"that probably means our SQL is invalid"): >
se.printStackTrace():
System.exit(l):
}
System.out.println("Successfully modified " + m + " rows.\n"):