X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/blobdiff_plain/475e6c234d491cc07dd24a09a2dc3b675b4eac11..23d65c7be2bd24020cab95650e5e7892a78fd770:/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/ICdmDataSource.java
diff --git a/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/ICdmDataSource.java b/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/ICdmDataSource.java
index e36d80ad90..60c6fe2565 100644
--- a/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/ICdmDataSource.java
+++ b/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/ICdmDataSource.java
@@ -9,15 +9,19 @@
package eu.etaxonomy.cdm.database;
-import org.hibernate.cache.CacheProvider;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.hibernate.cache.spi.RegionFactory;
import org.springframework.beans.factory.config.BeanDefinition;
-import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
public interface ICdmDataSource {
/**
- * Returns a BeanDefinition object of type DriverManagerDataSource that contains
+ * Returns a BeanDefinition object of type DataSource that contains
* datsource properties (url, username, password, ...)
* @return BeanDefinition
*/
@@ -36,7 +40,7 @@ public interface ICdmDataSource {
* @param cacheProviderClass
* @return BeanDefinition
*/
- public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll, Boolean showSql, Boolean formatSql, Class extends CacheProvider> cacheProviderClass);
+ public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll, Boolean showSql, Boolean formatSql, Boolean registerSearchListener, Class extends RegionFactory> cacheProviderClass);
/**
@@ -52,10 +56,16 @@ public interface ICdmDataSource {
public String getServer();
/**
+ * Returns the name of the datasource on the given server.
* @return
*/
public String getDatabase();
+ /**
+ * Returns the database type of the data source.
+ * @return the database type of the data source.
+ * null
if the bean or the driver class property does not exist or the driver class is unknown.
+ */
public DatabaseTypeEnum getDatabaseType();
/**
@@ -73,17 +83,84 @@ public interface ICdmDataSource {
*/
public H2Mode getMode();
-
/**
* Tests, if a database connection can be established.
* @return true if test was successful, false otherwise
+ * @throws ClassNotFoundException
+ * @throws SQLException
+ * @throws Exception
*/
- public boolean testConnection();
+ public boolean testConnection() throws ClassNotFoundException, SQLException;
public String getUsername();
public String getPassword();
+ /**
+ * Executes a query and returns the ResultSet.
+ * @return ResultSet for the query.
+ * @throws SQLException
+ */
+ public ResultSet executeQuery (String query) throws SQLException;
+
+ /**
+ * Executes an update
+ * @return return code
+ */
+ public int executeUpdate (String sqlUpdate) throws SQLException;
+
+ /**
+ * Starts a transaction for the given datasource.
+ */
+ public void startTransaction();
+
+ /**
+ * Commits the transaction for the given datasource.
+ * @return
+ * @throws SQLException
+ */
+ public void commitTransaction() throws SQLException;
+
+ /**
+ * Rolls the connection back.
+ * @throws SQLException
+ */
+ public void rollback() throws SQLException;
+
+
+ public NomenclaturalCode getNomenclaturalCode();
+
+ /**
+ * Returns the first value of the first row of a result set.
+ * If no row exists in the result set
+ * null
is returned.
+ *
+ * Caution This method opens a connection on first use. Subsequent calls will use the same connection.
+ * Please close the connection when not needed anymore with {@link ICdmDataSource#closeOpenConnections()}
+ *
+ * @param query
+ * @return
+ * @throws SQLException
+ */
+ public Object getSingleValue(String query) throws SQLException;
+
+ /**
+ * Returns {@link DatabaseMetaData} for this
datasource.
+ *
+ *
+ *
+ * Caution This method opens a connection that should be closed
+ * with {@link #closeOpenConnections()}
+ *
+ * @return
+ */
+ public DatabaseMetaData getMetaData();
+
+ /**
+ *
+ */
+ public void closeOpenConnections();
+
//
// public void setFilePath(String filePath);