## org.h2.util
Class JdbcUtils

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

    public class JdbcUtils

extends java.lang.Object

This is a utility class with JDBC helper functions.

Field Summary
`static JavaObjectSerializer` `serializer` The serializer to use.

Method Summary
`static void` `addClassFactory(Utils.ClassFactory classFactory)` Add a class factory in order to manage more than one class loader.
`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 java.lang.Object` `deserialize(byte[] data, DataHandler dataHandler)` De-serialize the byte array to an object, eventually using the serializer specified by the connection info.
`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.
`static java.lang.Class<?>` `loadUserClass(java.lang.String className)` Load a class, but check if it is allowed to load this class first.
`static void` `removeClassFactory(Utils.ClassFactory classFactory)` Remove a class factory
`static byte[]` `serialize(java.lang.Object obj, DataHandler dataHandler)` Serialize the object to a byte array, using the serializer specified by the connection info if set, or the default serializer.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### serializer

    public static JavaObjectSerializer serializer

  The serializer to use.

Method Detail

### addClassFactory

    public static void addClassFactory(Utils.ClassFactory classFactory)

  Add a class factory in order to manage more than one class loader.

  Parameters:
    `classFactory` - An object that implements ClassFactory

### removeClassFactory

    public static void removeClassFactory(Utils.ClassFactory classFactory)

  Remove a class factory

  Parameters:
    `classFactory` - Already inserted class factory instance

### loadUserClass

    public static java.lang.Class<?> loadUserClass(java.lang.String className)

  Load a class, but check if it is allowed to load this class first. To perform access rights checking, the system property h2.allowedClasses needs to be set to a list of class file name prefixes.

  Parameters:
    `className` - the name of the class
  Returns:
    the class object

### 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

### 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`

### 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

### serialize

    public static byte[] serialize(java.lang.Object obj,
                                   DataHandler dataHandler)

  Serialize the object to a byte array, using the serializer specified by the connection info if set, or the default serializer.

  Parameters:
    `obj` - the object to serialize
    `dataHandler` - provides the object serializer (may be null)
  Returns:
    the byte array

### deserialize

    public static java.lang.Object deserialize(byte[] data,
                                               DataHandler dataHandler)

  De-serialize the byte array to an object, eventually using the serializer specified by the connection info.

  Parameters:
    `data` - the byte array
    `dataHandler` - provides the object serializer (may be null)
  Returns:
    the object
  Throws:
    `DbException` - if serialization fails