Package org.europa.together.application
Class JdbcActions
- java.lang.Object
-
- org.europa.together.application.JdbcActions
-
- All Implemented Interfaces:
DatabaseActions
@Repository @FeatureToggle(featureID="CM-0008") public class JdbcActions extends Object implements DatabaseActions
Implementation of Database JDBC Actions.
-
-
Field Summary
-
Fields inherited from interface org.europa.together.business.DatabaseActions
FEATURE_ID
-
-
Constructor Summary
Constructors Constructor Description JdbcActions()
Constructor.JdbcActions(boolean activateTestMode)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete 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.
-
-
-
Constructor Detail
-
JdbcActions
@FeatureToggle(featureID="CM-0008.CO01") public JdbcActions()
Constructor.
-
JdbcActions
@FeatureToggle(featureID="CM-0008.CO02") public JdbcActions(boolean activateTestMode)
Constructor.- Parameters:
activateTestMode
- as boolean
-
-
Method Detail
-
connect
public boolean connect(String propertyFile)
Description copied from interface:DatabaseActions
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.- Specified by:
connect
in interfaceDatabaseActions
- Parameters:
propertyFile
- as String- Returns:
- true on success
-
executeSqlFromClasspath
public boolean executeSqlFromClasspath(String sqlFile)
Description copied from interface:DatabaseActions
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.- Specified by:
executeSqlFromClasspath
in interfaceDatabaseActions
- Parameters:
sqlFile
- as String- Returns:
- true on success
-
executeQuery
public boolean executeQuery(String sql)
Description copied from interface:DatabaseActions
Execute a plain SQL Query.- Specified by:
executeQuery
in interfaceDatabaseActions
- Parameters:
sql
- as String- Returns:
- true on success
-
getResultCount
public int getResultCount()
Description copied from interface:DatabaseActions
Count the entries of an ResultSet.- Specified by:
getResultCount
in interfaceDatabaseActions
- Returns:
- count as int
-
getResultSet
public ResultSet getResultSet()
Description copied from interface:DatabaseActions
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.- Specified by:
getResultSet
in interfaceDatabaseActions
- Returns:
- results as ResultSet
-
getPort
public int getPort()
Description copied from interface:DatabaseActions
Get the port for the configured database connection.- Specified by:
getPort
in interfaceDatabaseActions
- Returns:
- port as int
-
getUri
public String getUri()
Description copied from interface:DatabaseActions
Get the host URL / IP of the configured Database connection.- Specified by:
getUri
in interfaceDatabaseActions
- Returns:
- uri as String
-
getJdbcMetaData
public JdbcConnection getJdbcMetaData()
Description copied from interface:DatabaseActions
Return a object with all JDBC Connection meta date.- Specified by:
getJdbcMetaData
in interfaceDatabaseActions
- Returns:
- JdbcConnection as Object
-
-