\r
package eu.etaxonomy.cdm.database;\r
\r
+import java.sql.DatabaseMetaData;\r
+import java.sql.ResultSet;\r
+import java.sql.SQLException;\r
+\r
import org.hibernate.cache.CacheProvider;\r
import org.springframework.beans.factory.config.BeanDefinition;\r
\r
-import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;\r
\r
public interface ICdmDataSource {\r
\r
/**\r
- * Returns a BeanDefinition object of type DriverManagerDataSource that contains\r
+ * Returns a BeanDefinition object of type DataSource that contains\r
* datsource properties (url, username, password, ...)\r
- * @return\r
+ * @return BeanDefinition\r
*/\r
public BeanDefinition getDatasourceBean();\r
\r
/**\r
* @param hbm2dll\r
- * @param showSql\r
- * @return\r
+ * @return BeanDefinition\r
*/\r
public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll);\r
\r
/**\r
* @param hbm2dll\r
* @param showSql\r
- * @return\r
+ * @param formatSql\r
+ * @param cacheProviderClass\r
+ * @return BeanDefinition\r
*/\r
- public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll, Boolean showSql, Boolean formatSql, Class<? extends CacheProvider> cacheProviderClass);\r
+ public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll, Boolean showSql, Boolean formatSql, Boolean registerSearchListener, Class<? extends CacheProvider> cacheProviderClass);\r
\r
\r
/**\r
- * @param hbm2dll\r
- * @param showSql\r
+ * The name representation of thie Datasource.\r
* @return\r
*/\r
public String getName();\r
+ \r
+\r
+ /**\r
+ * @return\r
+ */\r
+ public String getServer();\r
+\r
+ /**\r
+ * @return\r
+ */\r
+ public String getDatabase();\r
+ \r
+ public DatabaseTypeEnum getDatabaseType();\r
+ \r
+ /**\r
+ * @return\r
+ */\r
+ public int getPort();\r
+\r
+ /**\r
+ * @return\r
+ */\r
+ public String getFilePath();\r
+\r
+ /**\r
+ * @return\r
+ */\r
+ public H2Mode getMode();\r
+ \r
+ /**\r
+ * Tests, if a database connection can be established.\r
+ * @return true if test was successful, false otherwise\r
+ * @throws ClassNotFoundException \r
+ * @throws SQLException \r
+ * @throws Exception \r
+ */\r
+ public boolean testConnection() throws ClassNotFoundException, SQLException;\r
+ \r
+ public String getUsername();\r
+ \r
+ public String getPassword();\r
+ \r
+ /**\r
+ * Executes a query and returns the ResultSet.\r
+ * @return ResultSet for the query.\r
+ * @throws SQLException \r
+ */\r
+ public ResultSet executeQuery (String query) throws SQLException;\r
+ \r
+ /**\r
+ * Executes an update\r
+ * @return return code\r
+ */\r
+ public int executeUpdate (String sqlUpdate) throws SQLException;\r
+ \r
+ /**\r
+ * Starts a transaction for the given datasource.\r
+ */\r
+ public void startTransaction();\r
+ \r
+ /**\r
+ * Commits the transaction for the given datasource.\r
+ * @return\r
+ * @throws SQLException \r
+ */\r
+ public void commitTransaction() throws SQLException;\r
+ \r
+ /**\r
+ * Rolls the connection back.\r
+ * @throws SQLException \r
+ */\r
+ public void rollback() throws SQLException;\r
+\r
+\r
+ public NomenclaturalCode getNomenclaturalCode();\r
+\r
+ /**\r
+ * Returns a single the first value of a row of a resultset.\r
+ * \r
+ * <strong>Caution</strong> This method opens a connection on first use. Subsequent calls will use the same connection.\r
+ * Please close the connection when not needed anymore with {@link ICdmDataSource#closeOpenConnections()}\r
+ * \r
+ * @param query\r
+ * @return\r
+ * @throws SQLException\r
+ */\r
+ public Object getSingleValue(String query) throws SQLException; \r
+ \r
+ /**\r
+ * Returns {@link DatabaseMetaData} for <code>this</code> datasource.\r
+ * \r
+ * <br>\r
+ * <br>\r
+ * <strong>Caution</strong> This method opens a connection that should be closed\r
+ * with {@link #closeOpenConnections()}\r
+ * \r
+ * @return\r
+ */\r
+ public DatabaseMetaData getMetaData();\r
+ \r
+ /**\r
+ * \r
+ */\r
+ public void closeOpenConnections();\r
+\r
+ \r
+//\r
+// public void setFilePath(String filePath);\r
+// \r
+// public void setMode(H2Mode mode);\r
\r
}
\ No newline at end of file