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[] argv) throws Exception {
    String driverName = "com.jnetdirect.jsql.JSQLDriver";
    Class.forName(driverName);//from   ww w .  j  av  a 2s . c  om

    String serverName = "127.0.0.1";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String url = "jdbc:JSQLConnect://" + mydatabase;
    String username = "username";
    String password = "password";

    Connection connection = DriverManager.getConnection(url, username, password);
    DatabaseMetaData dbmd = connection.getMetaData();
    // Get max table name length
    int length = dbmd.getMaxTableNameLength();
    System.out.println(length);

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Class.forName(DRIVER);//from   w w w.  j ava2  s  . c  om
    Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
    DatabaseMetaData metadata = connection.getMetaData();
    String[] functions = metadata.getTimeDateFunctions().split(",\\s*");

    for (int i = 0; i < functions.length; i++) {
        String function = functions[i];
        System.out.println("Function = " + function);
    }
    connection.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Class.forName(DRIVER);/*from  w  w  w  .  j  av a 2  s.  c  om*/
    Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
    DatabaseMetaData metadata = connection.getMetaData();

    String[] functions = metadata.getSystemFunctions().split(",\\s*");

    for (int i = 0; i < functions.length; i++) {
        String function = functions[i];
        System.out.println("Function = " + function);
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String driverName = "com.jnetdirect.jsql.JSQLDriver";
    Class.forName(driverName);/*from w w  w.  j  av a  2  s. co m*/

    String serverName = "127.0.0.1";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String url = "jdbc:JSQLConnect://" + mydatabase;
    String username = "username";
    String password = "password";

    Connection connection = DriverManager.getConnection(url, username, password);
    DatabaseMetaData dbmd = connection.getMetaData();
    // Get the list of string functions
    String[] stringFunctions = dbmd.getStringFunctions().split(",\\s*");
    Arrays.toString(stringFunctions);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String driverName = "com.jnetdirect.jsql.JSQLDriver";
    Class.forName(driverName);//from   w  w  w .java2  s  . c o  m

    String serverName = "127.0.0.1";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String url = "jdbc:JSQLConnect://" + mydatabase;
    String username = "username";
    String password = "password";

    Connection connection = DriverManager.getConnection(url, username, password);
    DatabaseMetaData dbmd = connection.getMetaData();
    // Get the list of numeric functions
    String[] numericFunctions = dbmd.getNumericFunctions().split(",\\s*");
    Arrays.toString(numericFunctions);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String driverName = "com.jnetdirect.jsql.JSQLDriver";
    Class.forName(driverName);/*from w  w w.  j a  va2s.  c  o m*/

    String serverName = "127.0.0.1";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String url = "jdbc:JSQLConnect://" + mydatabase;
    String username = "username";
    String password = "password";

    Connection connection = DriverManager.getConnection(url, username, password);
    DatabaseMetaData dbmd = connection.getMetaData();
    // Get the list of system functions
    String[] systemFunctions = dbmd.getSystemFunctions().split(",\\s*");
    Arrays.toString(systemFunctions);

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Class.forName(DRIVER);/*from w  w w .  j  a va  2 s  . c  om*/
    Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
    DatabaseMetaData metadata = connection.getMetaData();

    String[] functions = metadata.getStringFunctions().split(",\\s*");

    for (int i = 0; i < functions.length; i++) {
        String function = functions[i];
        System.out.println("Function = " + function);
    }
    connection.close();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String driverName = "com.jnetdirect.jsql.JSQLDriver";
    Class.forName(driverName);//from  ww w  . ja  v  a 2  s.com

    String serverName = "127.0.0.1";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String url = "jdbc:JSQLConnect://" + mydatabase;
    String username = "username";
    String password = "password";

    Connection connection = DriverManager.getConnection(url, username, password);
    DatabaseMetaData dmd = connection.getMetaData();
    if (dmd.supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)) {
        System.out.println("Updatable result sets are supported");
    } else {
        System.out.println("Updatable result sets are not supported");
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String driverName = "com.jnetdirect.jsql.JSQLDriver";
    Class.forName(driverName);//from  w w  w.j  a  va  2 s.co  m

    String serverName = "127.0.0.1";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String url = "jdbc:JSQLConnect://" + mydatabase;
    String username = "username";
    String password = "password";

    Connection connection = DriverManager.getConnection(url, username, password);
    DatabaseMetaData dbmd = connection.getMetaData();

    // Get the list of time and date functions
    String timedateFunctions[] = dbmd.getTimeDateFunctions().split(",\\s*");
    Arrays.toString(timedateFunctions);

}

From source file:Main.java

public static void main(String[] args) throws Exception {

    Class.forName(DRIVER);//from  w w  w  .j a  v  a2 s  .  c  o  m
    Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
    DatabaseMetaData metadata = connection.getMetaData();

    String[] functions = metadata.getNumericFunctions().split(",\\s*");

    for (int i = 0; i < functions.length; i++) {
        String function = functions[i];
        System.out.println("Function = " + function);
    }
    connection.close();
}