JdbcUtils

This is a utility class with JDBC helper functions.

Methods
static void addClassFactory(Utils.ClassFactory classFactory)
Add a class factory in order to manage more than one class loader.
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
static void closeSilently(Statement stat)
Close a statement without throwing an exception.
static void closeSilently(Statement stat)
Close a statement without throwing an exception.
Parameters:
stat - the statement or null
static void closeSilently(Connection conn)
Close a connection without throwing an exception.
static void closeSilently(Connection conn)
Close a connection without throwing an exception.
Parameters:
conn - the connection or null
static void closeSilently(ResultSet rs)
Close a result set without throwing an exception.
static void closeSilently(ResultSet rs)
Close a result set without throwing an exception.
Parameters:
rs - the result set or null
static Object deserialize(byte[] data, DataHandler dataHandler)
De-serialize the byte array to an object, eventually using the serializer specified by the connection info.
static 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
static Connection getConnection(String driver, String url, String user, String password)
Open a new database connection with the given settings.
static Connection getConnection(String driver, String url, String user, String password) throws 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
static Connection getConnection(String driver, String url, Properties prop)
Open a new database connection with the given settings.
static Connection getConnection(String driver, String url, Properties prop) throws 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
static String getDriver(String url)
Get the driver class name for the given URL, or null if the URL is unknown.
static String getDriver(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
static void load(String url)
Load the driver class for the given URL, if the database URL is known.
static void load(String url)
Load the driver class for the given URL, if the database URL is known.
Parameters:
url - the database URL
static Class loadUserClass(String className)
Load a class, but check if it is allowed to load this class first.
static Class loadUserClass(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
static void removeClassFactory(Utils.ClassFactory classFactory)
Remove a class factory
static void removeClassFactory(Utils.ClassFactory classFactory)
Remove a class factory
Parameters:
classFactory - Already inserted class factory instance
static byte[] serialize(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.
static byte[] serialize(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

Fields
static CustomDataTypesHandler customDataTypesHandler
static JavaObjectSerializer serializer

customDataTypesHandler

Custom data types handler to use.

serializer

The serializer to use.