Package org.europa.together.business
Interface DatabaseActions
-
- All Known Implementing Classes:
JdbcActions
@API(status=STABLE, since="1.0") @Component public interface DatabaseActions
DatabaseActions is a simple helper class to execute SQL queries and other database operations out of the DAO Context. To establish a JDBC Connection for Unit Tests call the Constructor:
DatabaseActions(boolean activateTestMode);- Since:
- 1.0
- Version:
- 2.0
- Author:
- [email protected]
-
-
Field Summary
Fields Modifier and Type Field Description static String
FEATURE_ID
Identifier for the given feature to enable toggles.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
connect(String propertyFile)
Establish an JDBC Connection.boolean
executeQuery(String sql)
Execute a plain SQL Query.boolean
executeSqlFromClasspath(String sqlFile)
Load an SQL File from the classpath and execute the script.JdbcConnection
getJdbcMetaData()
Return a object with all JDBC Connection meta date.int
getPort()
Get the port for the configured database connection.int
getResultCount()
Count the entries of an ResultSet.ResultSet
getResultSet()
Get the ResultSet from an SQL Query.String
getUri()
Get the host URL / IP of the configured Database connection.
-
-
-
Field Detail
-
FEATURE_ID
@API(status=STABLE, since="1.2") static final String FEATURE_ID
Identifier for the given feature to enable toggles.- See Also:
- Constant Field Values
-
-
Method Detail
-
connect
@API(status=STABLE, since="1.0") boolean connect(String propertyFile)
Establish an JDBC Connection. If the propertyFile Parameter is empty, then the Method load by default the configuration from the classpath. The path to the external property file have to be relative to the execution path.- Parameters:
propertyFile
- as String- Returns:
- true on success
-
executeQuery
@API(status=STABLE, since="1.0") boolean executeQuery(String sql)
Execute a plain SQL Query.- Parameters:
sql
- as String- Returns:
- true on success
-
executeSqlFromClasspath
@API(status=STABLE, since="1.0") boolean executeSqlFromClasspath(String sqlFile)
Load an SQL File from the classpath and execute the script. Attention: This function should be used to populate a database and so on. It is not designed to handle multiple ResultSets by using SELECT. If multiple SELECT statements appears in an SQL File, then only the ResultSet of the last SELECT statement will be available.
Internal call this function for each single SQL statement the executeQuery() method.- Parameters:
sqlFile
- as String- Returns:
- true on success
-
getPort
@API(status=STABLE, since="1.0") int getPort()
Get the port for the configured database connection.- Returns:
- port as int
-
getResultCount
@API(status=STABLE, since="1.0") int getResultCount()
Count the entries of an ResultSet.- Returns:
- count as int
-
getResultSet
@API(status=STABLE, since="1.0") ResultSet getResultSet()
Get the ResultSet from an SQL Query. RestultSet get produced by executeQuery(). If exist in an SQL File multiple SELECT statements, then the ResultSet contains only the rusultSet of the last SELECT statement.- Returns:
- results as ResultSet
-
getJdbcMetaData
@API(status=STABLE, since="1.2") JdbcConnection getJdbcMetaData()
Return a object with all JDBC Connection meta date.- Returns:
- JdbcConnection as Object
- Throws:
SQLException
-
getUri
@API(status=STABLE, since="1.0") String getUri()
Get the host URL / IP of the configured Database connection.- Returns:
- uri as String
-
-