integrating trunk
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / database / ICdmDataSource.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.cdm.database;
11
12 import java.sql.ResultSet;
13 import java.sql.SQLException;
14
15 import org.hibernate.cache.CacheProvider;
16 import org.springframework.beans.factory.config.BeanDefinition;
17
18 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
19
20 public interface ICdmDataSource {
21
22 /**
23 * Returns a BeanDefinition object of type DataSource that contains
24 * datsource properties (url, username, password, ...)
25 * @return BeanDefinition
26 */
27 public BeanDefinition getDatasourceBean();
28
29 /**
30 * @param hbm2dll
31 * @return BeanDefinition
32 */
33 public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll);
34
35 /**
36 * @param hbm2dll
37 * @param showSql
38 * @param formatSql
39 * @param cacheProviderClass
40 * @return BeanDefinition
41 */
42 public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll, Boolean showSql, Boolean formatSql, Boolean registerSearchListener, Class<? extends CacheProvider> cacheProviderClass);
43
44
45 /**
46 * The name representation of thie Datasource.
47 * @return
48 */
49 public String getName();
50
51
52 /**
53 * @return
54 */
55 public String getServer();
56
57 /**
58 * @return
59 */
60 public String getDatabase();
61
62 public DatabaseTypeEnum getDatabaseType();
63
64 /**
65 * @return
66 */
67 public int getPort();
68
69 /**
70 * @return
71 */
72 public String getFilePath();
73
74 /**
75 * @return
76 */
77 public H2Mode getMode();
78
79 /**
80 * Tests, if a database connection can be established.
81 * @return true if test was successful, false otherwise
82 * @throws Exception
83 */
84 public boolean testConnection() throws DataSourceNotFoundException;
85
86 public String getUsername();
87
88 public String getPassword();
89
90 /**
91 * Executes a query and returns the ResultSet.
92 * @return ResultSet for the query.
93 */
94 public ResultSet executeQuery (String query);
95
96 /**
97 * Executes an update
98 * @return return code
99 */
100 public int executeUpdate (String sqlUpdate);
101
102 public NomenclaturalCode getNomenclaturalCode();
103
104 public Object getSingleValue(String query) throws SQLException;
105
106 //
107 // public void setFilePath(String filePath);
108 //
109 // public void setMode(H2Mode mode);
110
111 }