Example usage for java.sql Connection getMetaData

List of usage examples for java.sql Connection getMetaData

Introduction

In this page you can find the example usage for java.sql Connection getMetaData.

Prototype

DatabaseMetaData getMetaData() throws SQLException;

Source Link

Document

Retrieves a DatabaseMetaData object that contains metadata about the database to which this Connection object represents a connection.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    Connection conn = getHSQLConnection();

    DatabaseMetaData md = conn.getMetaData();
    System.out//ww  w .  j ava 2  s . com
            .println("supportsDifferentTableCorrelationNames - " + md.supportsDifferentTableCorrelationNames());

    conn.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Connection conn = getHSQLConnection();

    DatabaseMetaData meta = conn.getMetaData();
    String sqlKeywords = meta.getSQLKeywords();
    System.out.println("sqlKeywords:" + sqlKeywords);

    conn.close();/* w w w.jav a2  s . c o  m*/
}

From source file:Main.java

public static void main(String[] a) throws Exception {
    Connection conn = getConnection();

    DatabaseMetaData dbMetaData = conn.getMetaData();

    System.out.println(dbMetaData.supportsTransactions());

    conn.close();//  w  ww  .j a  v  a2s.  c om
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Connection conn = getConnection();

    DatabaseMetaData dbmd = conn.getMetaData();
    if (dbmd.supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)) {
        System.out.println("Updatable ResultSets are supported");
    } else {/*from  ww w  .ja  v  a2s. com*/
        System.out.println("Updatable ResultSets are not supported");
    }

    conn.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Connection conn = getHSQLConnection();

    DatabaseMetaData md = conn.getMetaData();

    System.out.println("JDBC Driver: " + md.getDriverName() + " " + md.getDriverVersion());
    System.out.println("Database: " + md.getURL());
    System.out.println("User: " + md.getUserName());

    conn.close();//from  ww w  .j  a  va 2  s .co  m
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Connection conn = getConnection();

    DatabaseMetaData mtdt = conn.getMetaData();
    System.out.println("ANSI92 Entry Level: " + mtdt.supportsANSI92EntryLevelSQL());
    System.out.println("ANSI92 Intermediate: " + mtdt.supportsANSI92IntermediateSQL());
    System.out.println("ANSI92 Full SQL: " + mtdt.supportsANSI92FullSQL());
    System.out.println("Minimum SQL Grammar: " + mtdt.supportsMinimumSQLGrammar());
    System.out.println("Core SQL Grammar: " + mtdt.supportsCoreSQLGrammar());
    System.out.println("Extended SQL Grammar: " + mtdt.supportsExtendedSQLGrammar());

    conn.close();/*from   w w  w.j  a  v  a  2  s  .  com*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Connection conn = getHSQLConnection();

    DatabaseMetaData md = conn.getMetaData();

    ResultSet r = md.getColumns("", "", "yourTableName", "%");
    while (r.next())
        System.out.println("\t" + r.getString(4) + " : " + r.getString(6));

    conn.close();//from  w w w .  j a  v  a2 s .  c  o m
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Connection conn = getConnection();

    DatabaseMetaData dbMeta = conn.getMetaData();
    if (dbMeta.supportsResultSetHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
        System.out.println("this database hold cursors over commit");
    } else if (dbMeta.supportsResultSetHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT)) {
        System.out.println("this database close cursors at commit");
    }//from  w ww  . j av a2  s. c om
    conn.close();

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Connection conn = getHSQLConnection();

    DatabaseMetaData meta = conn.getMetaData();
    String productName = meta.getDatabaseProductName();
    String productVersion = meta.getDatabaseProductVersion();
    System.out.println("productName:" + productName);
    System.out.println("productVersion:" + productVersion);

    conn.close();//from   w  w  w . ja  v  a  2s .co m
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Connection conn = getConnection();

    DatabaseMetaData mtdt = conn.getMetaData();
    System.out.println("URL in use: " + mtdt.getURL());
    System.out.println("User name: " + mtdt.getUserName());
    System.out.println("DBMS name: " + mtdt.getDatabaseProductName());
    System.out.println("DBMS version: " + mtdt.getDatabaseProductVersion());
    System.out.println("Driver name: " + mtdt.getDriverName());
    System.out.println("Driver version: " + mtdt.getDriverVersion());
    System.out.println("supp. SQL Keywords: " + mtdt.getSQLKeywords());

    conn.close();/* w ww. ja  va  2  s.  co  m*/
}