org.h2.util
Class JdbcUtils

java.lang.Object
  extended by org.h2.util.JdbcUtils

public class JdbcUtils
extends java.lang.Object

This is a utility class with JDBC helper functions.


Method Summary
static void closeSilently(java.sql.Connection conn)
          Close a connection without throwing an exception.
static void closeSilently(java.sql.ResultSet rs)
          Close a result set without throwing an exception.
static void closeSilently(java.sql.Statement stat)
          Close a statement without throwing an exception.
static void closeSilently(javax.sql.XAConnection conn)
          Close an XA connection set without throwing an exception.
static java.lang.String escapeMetaDataPattern(java.lang.String pattern)
          Escape table or schema patterns used for DatabaseMetaData functions.
static java.sql.Connection getConnection(java.lang.String driver, java.lang.String url, java.util.Properties prop)
          Open a new database connection with the given settings.
static java.sql.Connection getConnection(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)
          Open a new database connection with the given settings.
static java.lang.String getDriver(java.lang.String url)
          Get the driver class name for the given URL, or null if the URL is unknown.
static void load(java.lang.String url)
          Load the driver class for the given URL, if the database URL is known.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

closeSilently

public static void closeSilently(java.sql.Statement stat)
Close a statement without throwing an exception.

Parameters:
stat - the statement or null

closeSilently

public static void closeSilently(java.sql.Connection conn)
Close a connection without throwing an exception.

Parameters:
conn - the connection or null

closeSilently

public static void closeSilently(java.sql.ResultSet rs)
Close a result set without throwing an exception.

Parameters:
rs - the result set or null

closeSilently

public static void closeSilently(javax.sql.XAConnection conn)
Close an XA connection set without throwing an exception.

Parameters:
conn - the XA connection or null

getConnection

public static java.sql.Connection getConnection(java.lang.String driver,
                                                java.lang.String url,
                                                java.lang.String user,
                                                java.lang.String password)
                                         throws java.sql.SQLException
Open a new database connection with the given settings.

Parameters:
driver - the driver class name
url - the database URL
user - the user name
password - the password
Returns:
the database connection
Throws:
java.sql.SQLException

escapeMetaDataPattern

public static java.lang.String escapeMetaDataPattern(java.lang.String pattern)
Escape table or schema patterns used for DatabaseMetaData functions.

Parameters:
pattern - the pattern
Returns:
the escaped pattern

getConnection

public static java.sql.Connection getConnection(java.lang.String driver,
                                                java.lang.String url,
                                                java.util.Properties prop)
                                         throws java.sql.SQLException
Open a new database connection with the given settings.

Parameters:
driver - the driver class name
url - the database URL
prop - the properties containing at least the user name and password
Returns:
the database connection
Throws:
java.sql.SQLException

getDriver

public static java.lang.String getDriver(java.lang.String url)
Get the driver class name for the given URL, or null if the URL is unknown.

Parameters:
url - the database URL
Returns:
the driver class name

load

public static void load(java.lang.String url)
Load the driver class for the given URL, if the database URL is known.

Parameters:
url - the database URL