Java 7 database enhancements:Get auto generated key : Database « JDK 7 « Java






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

1.Using the RowSetFactory class
2.Retrieving pseudo-columns
3.Controlling the type value of the OUT parameter
4.Get parent logger