Example usage for org.apache.commons.dbcp2 Utils closeQuietly

List of usage examples for org.apache.commons.dbcp2 Utils closeQuietly

Introduction

In this page you can find the example usage for org.apache.commons.dbcp2 Utils closeQuietly.

Prototype

public static void closeQuietly(Statement stmt) 

Source Link

Document

Closes the Statement (which may be null).

Usage

From source file:tools.datasync.core.sampleapp.CamelSeedIntegrationTests.java

private static Connection createConnection(String dbName, boolean create) {

    setupDerbyProps();/*from  w w  w  .jav  a  2 s.c o m*/

    try {
        Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        throw (new RuntimeException("Could not load derby driver"));
    }

    Connection conn = null;
    try {
        conn = DriverManager.getConnection("jdbc:derby:" + dbName + ";create=true");
    } catch (SQLException e) {
        Utils.closeQuietly(conn);
        throw (new RuntimeException(e));
    }
    return (conn);

}