Class GiDbUtils
java.lang.Object
edu.internet2.middleware.grouperInstaller.util.GiDbUtils
the instance can be reused, it doesnt store state except the connection user/pass etc
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheck connection to the dbcheck connection to the dbget a connection to the oracle DBstatic String
convertUrlToDriverClassIfNeeded
(String connectionUrl, String driverClassName) if there is no driver class specified, then try to derive it from the URLint
executeUpdate
(String query) execute a query (insert/update/delete/etc)int
executeUpdate
(String query, Object arg) 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)boolean
isMysql()
see if the config file seems to be mysqlstatic boolean
see if the config file seems to be mysqlboolean
isOracle()
see if the config file seems to be oraclestatic boolean
see if the config file seems to be oracleboolean
see if the config file seems to be postgresstatic 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 backvoid
registerDriverOnce
(String appDir) void
rollbackQuietly
(Connection connection) rollback quiently<T> T
select a value from the db
-
Constructor Details
-
GiDbUtils
construct- Parameters:
url
-user
-pass
-
-
-
Method Details
-
registerDriverOnce
- Parameters:
appDir
- where we can find drivers
-
isPostgres
public boolean isPostgres()see if the config file seems to be postgres- Returns:
- see if postgres
-
isPostgres
see if the config file seems to be postgres- Parameters:
connectionUrl
-- Returns:
- see if postgres
-
isOracle
public boolean isOracle()see if the config file seems to be oracle- Returns:
- see if oracle
-
isOracle
see if the config file seems to be oracle- Parameters:
connectionUrl
-- Returns:
- see if oracle
-
isMysql
public boolean isMysql()see if the config file seems to be mysql- Returns:
- see if mysql
-
isMysql
see if the config file seems to be mysql- Parameters:
connectionUrl
-- Returns:
- see if mysql
-
convertUrlToDriverClassIfNeeded
if there is no driver class specified, then try to derive it from the URL- Parameters:
connectionUrl
-driverClassName
-- Returns:
- the driver class
-
connection
get a connection to the oracle DB- Returns:
- a connection
-
listSelect
public <T> List<T> listSelect(Class<T> rowType, String query, List<GiDbUtils.DbType> returnColTypes) run a query and get rows back- Type Parameters:
T
- generic type- Parameters:
rowType
- type of each row returned, e.g. String.class or Object[]query
-returnColTypes
-- Returns:
- the list of objects
-
select
select a value from the db- Type Parameters:
T
-- Parameters:
colType
-query
-- Returns:
- the data
-
listSelect
public <T> List<T> listSelect(Class<T> rowType, String query, List<GiDbUtils.DbType> returnColTypes, List<Object> args) run a query and get rows back- Type Parameters:
T
- generic type- Parameters:
rowType
- type of each row returned, e.g. String.class or Object[]query
-returnColTypes
-args
- preparedstatement arguments- Returns:
- the list of objects
-
rollbackQuietly
rollback quiently- Parameters:
connection
-
-
executeUpdate
execute a query (insert/update/delete/etc)- Parameters:
query
- query to executearg
- preparedstatement argument- Returns:
- either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
-
executeUpdate
execute a query (insert/update/delete/etc)- Parameters:
query
- query to execute- Returns:
- either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
-
executeUpdate
execute a query (insert/update/delete/etc)- Parameters:
query
- query to executeargs
- preparedstatement arguments- Returns:
- either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
-
checkConnection
check connection to the db- Returns:
- exception if there is one
-
checkConnectionQuery
check connection to the db- Returns:
- the query to check connection with
-
executeUpdate
execute a query (insert/update/delete/etc)- Parameters:
query
- query to executeargs
- preparedstatement argumentscommit
- if we should commit- Returns:
- either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
-