public class DbUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
attach(Connection connection) |
static boolean |
blank(String str) |
static void |
closeConnection() |
static void |
closeQuietly(Object toClose) |
static Connection |
connection() |
static int |
countMigrations() |
static int |
countRows(String table) |
static DatabaseType |
databaseType(String url) |
static void |
detach() |
static String |
driverClass(String url)
Given a jdbc url, this tries to determine the target database and returns the driver class name as a string.
|
static int |
exec(String statement) |
static String |
extractDatabaseName(String url)
Given a JDBC connection URL, extract only the database name.
|
static String |
extractServerUrl(String url)
Given a JDBC connection URL, generate a new connection URL to connect directly to the database server itself (ie: no database specified).
|
static void |
openConnection(String driver,
String url,
String username,
String password) |
public static String driverClass(String url)
url
- jdbc urlpublic static DatabaseType databaseType(String url)
public static String extractDatabaseName(String url)
url
- a JDBC connection URLpublic static String extractServerUrl(String url)
url
- a JDBC connection URLpublic static Connection connection()
public static int exec(String statement)
public static void closeQuietly(Object toClose)
public static void openConnection(String driver, String url, String username, String password)
public static void attach(Connection connection)
public static void detach()
public static void closeConnection()
public static boolean blank(String str)
public static int countMigrations()
public static int countRows(String table)
Copyright © 2019 JavaLite. All rights reserved.