Java 7 database enhancements:Get auto generated key
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
public class Test {
public static void main(String[] args) throws Exception {
Connection con = DriverManager.getConnection(
"jdbc:derby://localhost:1527/contact", "userName", "password");
System.out.println("Schema: " + con.getSchema());
DatabaseMetaData metaData = con.getMetaData();
System.out.println("Auto Generated Keys: "
+ metaData.generatedKeyAlwaysReturned());
}
}
Related examples in the same category