Java examples for JDBC:Key
Check if JDBC always returns the generated key
import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.DriverManager; import java.sql.SQLException; public class Main { public static void main(String[] args) { try {// www .j a va2 s . c om 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()); } catch (SQLException ex) { ex.printStackTrace(); } } }