Project

General

Profile

Download (3.77 KB) Statistics
| Branch: | Tag: | Revision:
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.config.ICdmSource;
22

    
23
public interface ICdmDataSource  extends DataSource,ICdmSource {
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
	 * @return
50
	 */
51
	public String getFilePath();
52

    
53
	/**
54
	 * @return
55
	 */
56
	public H2Mode getMode();
57

    
58
	public String getUsername();
59

    
60
	public String getPassword();
61

    
62
	public String getDatabase();
63

    
64
	public void setMode(H2Mode h2Mode);
65

    
66
	public void setUsername(String username);
67

    
68
	public void setPassword(String password);
69

    
70
	public void setDatabase(String database);
71

    
72

    
73
	/**
74
	 * Returns the database type of the data source.
75
	 * @return the database type of the data source.
76
	 * <code>null</code> if the bean or the driver class property does not exist or the driver class is unknown.
77
	 */
78
	public DatabaseTypeEnum getDatabaseType();
79
	/**
80
	 * Tests, if a database connection can be established.
81
	 * @return true if test was successful, false otherwise
82
	 * @throws ClassNotFoundException
83
	 * @throws SQLException
84
	 * @throws Exception
85
	 */
86
	public boolean testConnection() throws ClassNotFoundException, SQLException;
87

    
88

    
89
	 /**
90
     * Executes a query and returns the ResultSet.
91
     * @return ResultSet for the query.
92
	 * @throws SQLException
93
     */
94
	public ResultSet executeQuery (String query) throws SQLException;
95

    
96
    /**
97
     * Executes an update
98
     * @return return code
99
     */
100
	public int executeUpdate (String sqlUpdate) throws SQLException;
101

    
102
	/**
103
	 * Starts a transaction for the given datasource.
104
	 */
105
	public void startTransaction();
106

    
107
	/**
108
	 * Commits the transaction for the given datasource.
109
	 * @return
110
	 * @throws SQLException
111
	 */
112
	public void commitTransaction() throws SQLException;
113

    
114
	/**
115
	 * Rolls the connection back.
116
	 * @throws SQLException
117
	 */
118
	public void rollback() throws SQLException;
119

    
120

    
121
	/**
122
	 * Returns the first value of the first row of a result set.<BR>
123
	 * If no row exists in the result set
124
	 * <code>null</code> is returned.
125
	 *
126
	 * <strong>Caution</strong> This method opens a connection on first use. Subsequent calls will use the same connection.
127
	 * Please close the connection when not needed anymore with {@link ICdmDataSource#closeOpenConnections()}
128
	 *
129
	 * @param query
130
	 * @return
131
	 * @throws SQLException
132
	 */
133
	public Object getSingleValue(String query) throws SQLException;
134

    
135
	/**
136
	 * Returns {@link DatabaseMetaData} for <code>this</code> datasource.
137
	 *
138
	 * <br>
139
	 * <br>
140
	 * <strong>Caution</strong> This method opens a connection that should be closed
141
	 * with {@link #closeOpenConnections()}
142
	 *
143
	 * @return
144
	 */
145
	public DatabaseMetaData getMetaData();
146

    
147
}
(13-13/20)