public class GiDbUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
GiDbUtils.DbType
oracle types
|
Constructor and Description |
---|
GiDbUtils(String url,
String user,
String pass)
construct
|
Modifier and Type | Method and Description |
---|---|
Exception |
checkConnection()
check connection to the db
|
String |
checkConnectionQuery()
check connection to the db
|
Connection |
connection()
get a connection to the oracle DB
|
static String |
convertUrlToDriverClassIfNeeded(String connectionUrl,
String driverClassName)
if there is no driver class specified, then try to derive it from the URL
|
int |
executeUpdate(String query)
execute a query (insert/update/delete/etc)
|
int |
executeUpdate(String query,
List<Object> args)
execute a query (insert/update/delete/etc)
|
int |
executeUpdate(String query,
List<Object> args,
boolean commit)
execute a query (insert/update/delete/etc)
|
int |
executeUpdate(String query,
Object arg)
execute a query (insert/update/delete/etc)
|
boolean |
isMysql()
see if the config file seems to be mysql
|
static boolean |
isMysql(String connectionUrl)
see if the config file seems to be mysql
|
boolean |
isOracle()
see if the config file seems to be oracle
|
static boolean |
isOracle(String connectionUrl)
see if the config file seems to be oracle
|
boolean |
isPostgres()
see if the config file seems to be postgres
|
static boolean |
isPostgres(String connectionUrl)
see if the config file seems to be postgres
|
<T> List<T> |
listSelect(Class<T> rowType,
String query,
List<GiDbUtils.DbType> returnColTypes)
run a query and get rows back
|
<T> List<T> |
listSelect(Class<T> rowType,
String query,
List<GiDbUtils.DbType> returnColTypes,
List<Object> args)
run a query and get rows back
|
void |
registerDriverOnce(String appDir) |
void |
rollbackQuietly(Connection connection)
rollback quiently
|
<T> T |
select(Class<T> colType,
String query)
select a value from the db
|
public void registerDriverOnce(String appDir)
appDir
- where we can find driverspublic boolean isPostgres()
public static boolean isPostgres(String connectionUrl)
connectionUrl
- public boolean isOracle()
public static boolean isOracle(String connectionUrl)
connectionUrl
- public boolean isMysql()
public static boolean isMysql(String connectionUrl)
connectionUrl
- public static String convertUrlToDriverClassIfNeeded(String connectionUrl, String driverClassName)
connectionUrl
- driverClassName
- public Connection connection()
public <T> List<T> listSelect(Class<T> rowType, String query, List<GiDbUtils.DbType> returnColTypes)
T
- generic typerowType
- type of each row returned, e.g. String.class or Object[]query
- returnColTypes
- public <T> T select(Class<T> colType, String query)
T
- colType
- query
- public <T> List<T> listSelect(Class<T> rowType, String query, List<GiDbUtils.DbType> returnColTypes, List<Object> args)
T
- generic typerowType
- type of each row returned, e.g. String.class or Object[]query
- returnColTypes
- args
- preparedstatement argumentspublic void rollbackQuietly(Connection connection)
connection
- public int executeUpdate(String query, Object arg)
query
- query to executearg
- preparedstatement argumentpublic int executeUpdate(String query)
query
- query to executepublic int executeUpdate(String query, List<Object> args)
query
- query to executeargs
- preparedstatement argumentspublic Exception checkConnection()
public String checkConnectionQuery()
public int executeUpdate(String query, List<Object> args, boolean commit)
query
- query to executeargs
- preparedstatement argumentscommit
- if we should commitCopyright © 2016 Internet2. All rights reserved.