public class JdbcUtils extends Object
Modifier and Type | Field and Description |
---|---|
static CustomDataTypesHandler |
customDataTypesHandler
Custom data types handler to use.
|
static JavaObjectSerializer |
serializer
The serializer to use.
|
Modifier and Type | Method and Description |
---|---|
static void |
addClassFactory(Utils.ClassFactory classFactory)
Add a class factory in order to manage more than one class loader.
|
static void |
closeSilently(Connection conn)
Close a connection without throwing an exception.
|
static void |
closeSilently(ResultSet rs)
Close a result set without throwing an exception.
|
static void |
closeSilently(Statement stat)
Close a statement without throwing an exception.
|
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 Connection |
getConnection(String driver,
String url,
Properties prop)
Open a new database connection with the given settings.
|
static Connection |
getConnection(String driver,
String url,
String user,
String password)
Open a new database connection with the given settings.
|
static String |
getDriver(String url)
Get the driver class name for the given URL, or null if the URL is
unknown.
|
static void |
load(String url)
Load the driver class for the given URL, if the database URL is known.
|
static <Z> Class<Z> |
loadUserClass(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(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.
|
public static JavaObjectSerializer serializer
public static CustomDataTypesHandler customDataTypesHandler
public static void addClassFactory(Utils.ClassFactory classFactory)
classFactory
- An object that implements ClassFactorypublic static void removeClassFactory(Utils.ClassFactory classFactory)
classFactory
- Already inserted class factory instancepublic static <Z> Class<Z> loadUserClass(String className)
className
- the name of the classpublic static void closeSilently(Statement stat)
stat
- the statement or nullpublic static void closeSilently(Connection conn)
conn
- the connection or nullpublic static void closeSilently(ResultSet rs)
rs
- the result set or nullpublic static Connection getConnection(String driver, String url, String user, String password) throws SQLException
driver
- the driver class nameurl
- the database URLuser
- the user namepassword
- the passwordSQLException
public static Connection getConnection(String driver, String url, Properties prop) throws SQLException
driver
- the driver class nameurl
- the database URLprop
- the properties containing at least the user name and passwordSQLException
public static String getDriver(String url)
url
- the database URLpublic static void load(String url)
url
- the database URLpublic static byte[] serialize(Object obj, DataHandler dataHandler)
obj
- the object to serializedataHandler
- provides the object serializer (may be null)public static Object deserialize(byte[] data, DataHandler dataHandler)
data
- the byte arraydataHandler
- provides the object serializer (may be null)DbException
- if serialization failsCopyright © 2020 JBoss by Red Hat. All rights reserved.