Example usage for java.sql Connection close

List of usage examples for java.sql Connection close

Introduction

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

Prototype

void close() throws SQLException;

Source Link

Document

Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Connection con = null;
    PreparedStatement prepstmt;/* w w  w. j  a va 2  s.  c om*/
    prepstmt = con.prepareStatement("DELETE FROM tCust " + " WHERE custId = ?");

    prepstmt.setString(1, "1");
    prepstmt.executeUpdate();

    prepstmt.close();
    con.close();
}

From source file:Main.java

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

    DatabaseMetaData md = conn.getMetaData();
    System.out.println("supportsAlterTableWithDropColumn - "
            + md.supportsConvert(java.sql.Types.ARRAY, java.sql.Types.INTEGER));

    conn.close();
}

From source file:com.xpfriend.fixture.runner.example.ExampleJob.java

/**
 *  TEST_FB ???/*from w w w.  java2s . c  o m*/
 * @param args 1:?ID?2:??NAME?
 */
public static void main(String[] args) throws Exception {
    if (args.length < 2) {
        throw new IllegalArgumentException("args.length == " + args.length);
    }
    int id = Integer.parseInt(args[0]);
    String name = args[1];

    Connection connection = getConnection();
    try {
        updateDatabase(id, name, connection);
        connection.commit();
    } finally {
        connection.close();
    }
}

From source file:Main.java

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

    DatabaseMetaData md = conn.getMetaData();
    System.out.println("supportsResultSetType - "
            + md.supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.FETCH_UNKNOWN));

    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("getMaxTablesInSelect - " + md.getMaxTablesInSelect());
    System.out.println("getMaxColumnsInTable - " + md.getMaxColumnsInTable());
    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("supportsTransactionIsolationLevel - "
            + md.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED));

    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("supportsDataDefinitionAndDataManipulationTransactions - "
            + md.supportsDataDefinitionAndDataManipulationTransactions());

    conn.close();
}

From source file:Main.java

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

    Class.forName(DRIVER);/*  www  .ja v a2s.  co  m*/
    Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
    DatabaseMetaData metadata = connection.getMetaData();

    int maxLength = metadata.getMaxTableNameLength();
    System.out.println("Max Table Name Length = " + maxLength);
    connection.close();
}

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 source file:Main.java

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

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

    int maxConnection = metadata.getMaxConnections();
    System.out.println("Maximum Connection = " + maxConnection);
    connection.close();
}