X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/blobdiff_plain/9c8bf5d64e778de27ca3c738823c5e327a4c75e7..23d65c7be2bd24020cab95650e5e7892a78fd770:/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/ICdmDataSource.java?ds=sidebyside
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 24058e599c..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
@@ -1,39 +1,170 @@
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
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
+ * @return BeanDefinition
*/
public BeanDefinition getDatasourceBean();
/**
* @param hbm2dll
- * @param showSql
- * @return
+ * @return BeanDefinition
*/
public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll);
/**
* @param hbm2dll
* @param showSql
- * @return
+ * @param formatSql
+ * @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);
/**
- * @param hbm2dll
- * @param showSql
+ * The name representation of thie Datasource.
* @return
*/
public String getName();
+
+
+ /**
+ * @return
+ */
+ 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();
+
+ /**
+ * @return
+ */
+ public int getPort();
+
+ /**
+ * @return
+ */
+ public String getFilePath();
+
+ /**
+ * @return
+ */
+ 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() 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);
+//
+// public void setMode(H2Mode mode);
}
\ No newline at end of file