removing @Override for compatibility with java 1.6
[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.DatabaseMetaData;
13 import java.sql.ResultSet;
14 import java.sql.SQLException;
15
16 import javax.sql.DataSource;
17
18 import org.hibernate.cache.spi.RegionFactory;
19 import org.springframework.beans.factory.config.BeanDefinition;
20
21 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
22
23 public interface ICdmDataSource extends DataSource {
24
25 /**
26 * Returns a BeanDefinition object of type DataSource that contains
27 * datsource properties (url, username, password, ...)
28 * @return BeanDefinition
29 */
30 public BeanDefinition getDatasourceBean();
31
32 /**
33 * @param hbm2dll
34 * @return BeanDefinition
35 */
36 public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll);
37
38 /**
39 * @param hbm2dll
40 * @param showSql
41 * @param formatSql
42 * @param cacheProviderClass
43 * @return BeanDefinition
44 */
45 public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll, Boolean showSql, Boolean formatSql, Boolean registerSearchListener, Class<? extends RegionFactory> cacheProviderClass);
46
47
48 /**
49 * The name representation of thie Datasource.
50 * @return
51 */
52 public String getName();
53
54
55 /**
56 * @return
57 */
58 public String getServer();
59
60 /**
61 * Returns the name of the datasource on the given server.
62 * @return
63 */
64 public String getDatabase();
65
66 /**
67 * Returns the database type of the data source.
68 * @return the database type of the data source.
69 * <code>null</code> if the bean or the driver class property does not exist or the driver class is unknown.
70 */
71 public DatabaseTypeEnum getDatabaseType();
72
73 /**
74 * @return
75 */
76 public int getPort();
77
78 /**
79 * @return
80 */
81 public String getFilePath();
82
83 /**
84 * @return
85 */
86 public H2Mode getMode();
87
88 /**
89 * Tests, if a database connection can be established.
90 * @return true if test was successful, false otherwise
91 * @throws ClassNotFoundException
92 * @throws SQLException
93 * @throws Exception
94 */
95 public boolean testConnection() throws ClassNotFoundException, SQLException;
96
97 public String getUsername();
98
99 public String getPassword();
100
101 /**
102 * Executes a query and returns the ResultSet.
103 * @return ResultSet for the query.
104 * @throws SQLException
105 */
106 public ResultSet executeQuery (String query) throws SQLException;
107
108 /**
109 * Executes an update
110 * @return return code
111 */
112 public int executeUpdate (String sqlUpdate) throws SQLException;
113
114 /**
115 * Starts a transaction for the given datasource.
116 */
117 public void startTransaction();
118
119 /**
120 * Commits the transaction for the given datasource.
121 * @return
122 * @throws SQLException
123 */
124 public void commitTransaction() throws SQLException;
125
126 /**
127 * Rolls the connection back.
128 * @throws SQLException
129 */
130 public void rollback() throws SQLException;
131
132
133 public NomenclaturalCode getNomenclaturalCode();
134
135 /**
136 * Returns the first value of the first row of a result set.<BR>
137 * If no row exists in the result set
138 * <code>null</code> is returned.
139 *
140 * <strong>Caution</strong> This method opens a connection on first use. Subsequent calls will use the same connection.
141 * Please close the connection when not needed anymore with {@link ICdmDataSource#closeOpenConnections()}
142 *
143 * @param query
144 * @return
145 * @throws SQLException
146 */
147 public Object getSingleValue(String query) throws SQLException;
148
149 /**
150 * Returns {@link DatabaseMetaData} for <code>this</code> datasource.
151 *
152 * <br>
153 * <br>
154 * <strong>Caution</strong> This method opens a connection that should be closed
155 * with {@link #closeOpenConnections()}
156 *
157 * @return
158 */
159 public DatabaseMetaData getMetaData();
160
161 /**
162 *
163 */
164 public void closeOpenConnections();
165
166
167 //
168 // public void setFilePath(String filePath);
169 //
170 // public void setMode(H2Mode mode);
171
172 }