Project

General

Profile

Revision 32e833cb

ID32e833cb0f14e123b1b755c748e6490fc16cd3c5
Parent 2a562e3e
Child 1e918bbc

Added by Andreas Müller over 5 years ago

#4965 Implement general solution for getDatabase() in
WrappedCdmDataSource

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/DatabaseTypeEnum.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.SQLException;
14
import java.util.ArrayList;
15
import java.util.List;
16

  
17
import javax.sql.DataSource;
18

  
19
import org.apache.log4j.Logger;
20
import org.hibernate.dialect.Dialect;
21

  
22
import eu.etaxonomy.cdm.database.types.H2DatabaseType;
23
import eu.etaxonomy.cdm.database.types.HSqlDbDatabaseType;
24
import eu.etaxonomy.cdm.database.types.IDatabaseType;
25
import eu.etaxonomy.cdm.database.types.MySQLDatabaseType;
26
import eu.etaxonomy.cdm.database.types.OdbcDatabaseType;
27
import eu.etaxonomy.cdm.database.types.OracleDatabaseType;
28
import eu.etaxonomy.cdm.database.types.PostgreSQLDatabaseType;
29
import eu.etaxonomy.cdm.database.types.SqlServer2005DatabaseType;
30
import eu.etaxonomy.cdm.database.types.SybaseDatabaseType;
31

  
32
/**
33
 * @author a.mueller
34
 *
35
 */
36
public enum DatabaseTypeEnum {
37
	HSqlDb(1),
38
	MySQL(2),
39
	ODBC(3),
40
	PostgreSQL(4),
41
	Oracle(5),
42
	//SqlServer2000(6),
43
	SqlServer2005(7),
44
	Sybase(8),
45
	H2(9)
46
	;
47

  
48
	/**
49
	 *
50
	 */
51
	private static final String P6SPY_DRIVER_CLASS_NAME = "com.p6spy.engine.spy.P6SpyDriver";
52
	private boolean useP6Spy = false;
53

  
54

  
55
	/**
56
	 * @return the useP6Spy
57
	 */
58
	public boolean isUseP6Spy() {
59
		return useP6Spy;
60
	}
61

  
62
	/**
63
	 * @param useP6Spy the useP6Spy to set
64
	 */
65
	public void setUseP6Spy(boolean useP6Spy) {
66
		this.useP6Spy = useP6Spy;
67
	}
68

  
69
	/**
70
	 * Constructor
71
	 * @param i
72
	 */
73
	private DatabaseTypeEnum(int i) {
74
		switch(i)
75
        {
76
        	case 1:
77
        		this.dbType = new HSqlDbDatabaseType(); break;
78
        	case 2:
79
        		this.dbType = new MySQLDatabaseType(); break;
80
        	case 3:
81
        		this.dbType = new OdbcDatabaseType(); break;
82
        	case 4:
83
            	this.dbType = new PostgreSQLDatabaseType(); break;
84
        	case 5:
85
             	this.dbType = new OracleDatabaseType(); break;
86
//            case 6:
87
//            	this.dbType = new SqlServer2000DatabaseType(); break;
88
            case 7:
89
            	this.dbType = new SqlServer2005DatabaseType(); break;
90
            case 8:
91
            	this.dbType = new SybaseDatabaseType(); break;
92
            case 9:
93
            	this.dbType = new H2DatabaseType(); break;
94
            default:
95
                //TODO Exception
96
        }
97
	}
98

  
99
	public IDatabaseType getDatabaseType(){
100
		return dbType;
101
	}
102

  
103
 	//Logger
104
	private static final Logger logger = Logger.getLogger(DatabaseTypeEnum.class);
105
	protected IDatabaseType dbType;
106

  
107

  
108
    /**
109
     * @return
110
     */
111
    public String getName(){
112
    	return dbType.getName();
113
    }
114

  
115
	/**
116
	 * @return
117
	 */
118
	public String getDriverClassName(){
119
		if(useP6Spy){
120
			return P6SPY_DRIVER_CLASS_NAME;
121

  
122
		} else {
123
			return dbType.getClassString();
124
		}
125
	}
126

  
127
	/**
128
	 * Returns the DataSource class that the datasource needs to create a spring bean
129
	 * @return the DataSource class
130
	 */
131
	public Class<? extends DataSource> getDataSourceClass(){
132
		return dbType.getDataSourceClass();
133
	}
134

  
135
	/**
136
	 * @return
137
	 */
138
	public String getUrl(){
139
		return dbType.getUrlString();
140
	}
141

  
142
	/**
143
	 * @return
144
	 */
145
	public String getHibernateDialectCanonicalName(){
146
		return dbType.getHibernateDialectCanonicalName();
147
	}
148

  
149
    /**
150
     * @return
151
     */
152
    public int getDefaultPort(){
153
    	return dbType.getDefaultPort();
154
    }
155

  
156
	/**
157
     * returns the connection string
158
     * @param server the server, e.g. IP-Address
159
     * @param database the database name on the server (e.g. "testDB")
160
     * @param port the port number
161
     * @return the connection string
162
     */
163
    public String getConnectionString(ICdmDataSource cdmDataSource){
164
    	String result = dbType.getConnectionString(cdmDataSource);
165
    	logger.debug("Connection String: " + result);
166
        return result;
167
    }
168

  
169
    /**
170
     * Returns the {@link Dialect hibernate dialect} used for this database type.
171
	 * @return hibernate dialect
172
	 */
173
    public Dialect getHibernateDialect(){
174
    	Dialect result = dbType.getHibernateDialect();
175
    	return result;
176
    }
177

  
178
	/**
179
     * Returns the Name of the initialization method to be used when a hibernate datasource is created for this database
180
	 * @return String name of the init method
181
	 */
182
    public String getInitMethod(){
183
    	String result = dbType.getInitMethod();
184
    	logger.debug("InitMethod: " + result);
185
        return result;
186
    }
187

  
188
	/**
189
	 * Returns the Name of the destroying method to be used when a hibernate datasource representing this database is destroyed
190
	 * @return String name of the destroy method
191
	 */
192
    public String getDestroyMethod(){
193
    	String result = dbType.getDestroyMethod();
194
    	logger.debug("DestroyMethod: " + result);
195
        return result;
196
    }
197

  
198
    /**
199
     * Returns a List of all available DatabaseEnums.
200
     * @return List of DatabaseEnums
201
     */
202
    public static List<DatabaseTypeEnum> getAllTypes(){
203
    	List<DatabaseTypeEnum> result = new ArrayList<DatabaseTypeEnum>();
204
    	for (DatabaseTypeEnum dbEnum : DatabaseTypeEnum.values()){
205
    		result.add(dbEnum);
206
    	}
207
    	return result;
208
    }
209

  
210
    /**
211
     * Returns the DatabaseTypeEnum to a given DriverClass
212
     * @param strDriverClass
213
     * @return the according DatabaseTypeEnum. Null if the driver class does not exist.
214
     */
215
    public static DatabaseTypeEnum byDriverClass(String strDriverClass){
216
    	if (strDriverClass == null){
217
    	    return null;
218
    	}
219
        for (DatabaseTypeEnum dbEnum : DatabaseTypeEnum.values()){
220
    		if (dbEnum.getDriverClassName().equals(strDriverClass)){
221
    			return dbEnum;
222
    		}
223
    	}
224
    	logger.info("Unknown driver class: " + strDriverClass);
225
    	return null;
226
    }
227

  
228
    /**
229
     * @param metaData
230
     * @return
231
     */
232
    public static DatabaseTypeEnum byDatabaseMetaData(DatabaseMetaData metaData) {
233
        if (metaData == null){
234
            return null;
235
        }
236

  
237
        //driver
238
        String driver = null;
239
        try {
240
            driver = metaData.getDriverName();
241
        } catch (SQLException e) {
242
            //do nothing
243
        }
244
        DatabaseTypeEnum result = byDriverClass(driver);
245
        if (result != null){
246
            return result;
247
        }
248

  
249
        //product
250
        String product = null;
251
        try {
252
            product = metaData.getDatabaseProductName();
253
        } catch (SQLException e) {
254
            //do nothing
255
        }
256
        if (product == null){
257
            return null;
258
        }
259
        if (product.toLowerCase().matches("\\.*mysql\\.*")){
260
            return MySQL;
261
        }else if (product.toLowerCase().matches("\\.*hsqldb\\.*")) {
262
            return HSqlDb;
263
        }else if (product.toLowerCase().matches("\\.*oracle\\.*")) {
264
            return Oracle;
265
        }else if (product.toLowerCase().matches("\\.*sybase\\.*")) {
266
            return Sybase;
267
        }else if (product.toLowerCase().matches("\\.*odbc\\.*")) {
268
            return ODBC;
269
        }else if (product.toLowerCase().matches("\\.*postgresql\\.*")) {
270
            return PostgreSQL;
271
        }else if (product.toLowerCase().matches("\\.*sqlserver\\.*")) {
272
            //TODO we need to distinguish versions here once we have sql server 2008 database enum
273
//            metaData.getDatabaseProductVersion()
274
            return SqlServer2005;
275
        }else if (product.toLowerCase().matches("\\.*h2\\.*")) {
276
            return H2;
277
        }
278
        return null;
279
    }
280

  
281

  
282

  
283

  
284
}
285

  
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.SQLException;
14
import java.util.ArrayList;
15
import java.util.List;
16

  
17
import javax.sql.DataSource;
18

  
19
import org.apache.log4j.Logger;
20
import org.hibernate.dialect.Dialect;
21

  
22
import eu.etaxonomy.cdm.database.types.H2DatabaseType;
23
import eu.etaxonomy.cdm.database.types.HSqlDbDatabaseType;
24
import eu.etaxonomy.cdm.database.types.IDatabaseType;
25
import eu.etaxonomy.cdm.database.types.MySQLDatabaseType;
26
import eu.etaxonomy.cdm.database.types.OdbcDatabaseType;
27
import eu.etaxonomy.cdm.database.types.OracleDatabaseType;
28
import eu.etaxonomy.cdm.database.types.PostgreSQLDatabaseType;
29
import eu.etaxonomy.cdm.database.types.SqlServer2005DatabaseType;
30
import eu.etaxonomy.cdm.database.types.SybaseDatabaseType;
31

  
32
/**
33
 * @author a.mueller
34
 *
35
 */
36
public enum DatabaseTypeEnum {
37
	HSqlDb(1),
38
	MySQL(2),
39
	ODBC(3),
40
	PostgreSQL(4),
41
	Oracle(5),
42
	//SqlServer2000(6),
43
	SqlServer2005(7),
44
	Sybase(8),
45
	H2(9)
46
	;
47

  
48
	/**
49
	 *
50
	 */
51
	private static final String P6SPY_DRIVER_CLASS_NAME = "com.p6spy.engine.spy.P6SpyDriver";
52
	private boolean useP6Spy = false;
53

  
54

  
55
	/**
56
	 * @return the useP6Spy
57
	 */
58
	public boolean isUseP6Spy() {
59
		return useP6Spy;
60
	}
61

  
62
	/**
63
	 * @param useP6Spy the useP6Spy to set
64
	 */
65
	public void setUseP6Spy(boolean useP6Spy) {
66
		this.useP6Spy = useP6Spy;
67
	}
68

  
69
	/**
70
	 * Constructor
71
	 * @param i
72
	 */
73
	private DatabaseTypeEnum(int i) {
74
		switch(i)
75
        {
76
        	case 1:
77
        		this.dbType = new HSqlDbDatabaseType(); break;
78
        	case 2:
79
        		this.dbType = new MySQLDatabaseType(); break;
80
        	case 3:
81
        		this.dbType = new OdbcDatabaseType(); break;
82
        	case 4:
83
            	this.dbType = new PostgreSQLDatabaseType(); break;
84
        	case 5:
85
             	this.dbType = new OracleDatabaseType(); break;
86
//            case 6:
87
//            	this.dbType = new SqlServer2000DatabaseType(); break;
88
            case 7:
89
            	this.dbType = new SqlServer2005DatabaseType(); break;
90
            case 8:
91
            	this.dbType = new SybaseDatabaseType(); break;
92
            case 9:
93
            	this.dbType = new H2DatabaseType(); break;
94
            default:
95
                //TODO Exception
96
        }
97
	}
98

  
99
	public IDatabaseType getDatabaseType(){
100
		return dbType;
101
	}
102

  
103
 	//Logger
104
	private static final Logger logger = Logger.getLogger(DatabaseTypeEnum.class);
105
	protected IDatabaseType dbType;
106

  
107

  
108
    /**
109
     * @return
110
     */
111
    public String getName(){
112
    	return dbType.getName();
113
    }
114

  
115
	/**
116
	 * @return
117
	 */
118
	public String getDriverClassName(){
119
		if(useP6Spy){
120
			return P6SPY_DRIVER_CLASS_NAME;
121

  
122
		} else {
123
			return dbType.getClassString();
124
		}
125
	}
126

  
127
	/**
128
	 * Returns the DataSource class that the datasource needs to create a spring bean
129
	 * @return the DataSource class
130
	 */
131
	public Class<? extends DataSource> getDataSourceClass(){
132
		return dbType.getDataSourceClass();
133
	}
134

  
135
	/**
136
	 * @return
137
	 */
138
	public String getUrl(){
139
		return dbType.getUrlString();
140
	}
141

  
142
	/**
143
	 * @return
144
	 */
145
	public String getHibernateDialectCanonicalName(){
146
		return dbType.getHibernateDialectCanonicalName();
147
	}
148

  
149
    /**
150
     * @return
151
     */
152
    public int getDefaultPort(){
153
    	return dbType.getDefaultPort();
154
    }
155

  
156
	/**
157
     * returns the connection string
158
     * @param server the server, e.g. IP-Address
159
     * @param database the database name on the server (e.g. "testDB")
160
     * @param port the port number
161
     * @return the connection string
162
     */
163
    public String getConnectionString(ICdmDataSource cdmDataSource){
164
    	String result = dbType.getConnectionString(cdmDataSource);
165
    	logger.debug("Connection String: " + result);
166
        return result;
167
    }
168

  
169
    /**
170
     * Returns the {@link Dialect hibernate dialect} used for this database type.
171
	 * @return hibernate dialect
172
	 */
173
    public Dialect getHibernateDialect(){
174
    	Dialect result = dbType.getHibernateDialect();
175
    	return result;
176
    }
177

  
178
	/**
179
     * Returns the Name of the initialization method to be used when a hibernate datasource is created for this database
180
	 * @return String name of the init method
181
	 */
182
    public String getInitMethod(){
183
    	String result = dbType.getInitMethod();
184
    	logger.debug("InitMethod: " + result);
185
        return result;
186
    }
187

  
188
	/**
189
	 * Returns the Name of the destroying method to be used when a hibernate datasource representing this database is destroyed
190
	 * @return String name of the destroy method
191
	 */
192
    public String getDestroyMethod(){
193
    	String result = dbType.getDestroyMethod();
194
    	logger.debug("DestroyMethod: " + result);
195
        return result;
196
    }
197

  
198
    /**
199
     * Returns a List of all available DatabaseEnums.
200
     * @return List of DatabaseEnums
201
     */
202
    public static List<DatabaseTypeEnum> getAllTypes(){
203
    	List<DatabaseTypeEnum> result = new ArrayList<DatabaseTypeEnum>();
204
    	for (DatabaseTypeEnum dbEnum : DatabaseTypeEnum.values()){
205
    		result.add(dbEnum);
206
    	}
207
    	return result;
208
    }
209

  
210
    /**
211
     * Returns the DatabaseTypeEnum to a given DriverClass
212
     * @param strDriverClass
213
     * @return the according DatabaseTypeEnum. Null if the driver class does not exist.
214
     */
215
    public static DatabaseTypeEnum byDriverClass(String strDriverClass){
216
    	if (strDriverClass == null){
217
    	    return null;
218
    	}
219
        for (DatabaseTypeEnum dbEnum : DatabaseTypeEnum.values()){
220
    		if (dbEnum.getDriverClassName().equals(strDriverClass)){
221
    			return dbEnum;
222
    		}
223
    	}
224
    	logger.info("Unknown driver class: " + strDriverClass);
225
    	return null;
226
    }
227

  
228
    /**
229
     * @param metaData
230
     * @return
231
     */
232
    public static DatabaseTypeEnum byDatabaseMetaData(DatabaseMetaData metaData) {
233
        if (metaData == null){
234
            return null;
235
        }
236

  
237
        //driver
238
        String driver = null;
239
        try {
240
            driver = metaData.getDriverName();
241
        } catch (SQLException e) {
242
            //do nothing
243
        }
244
        DatabaseTypeEnum result = byDriverClass(driver);
245
        if (result != null){
246
            return result;
247
        }
248

  
249
        //product
250
        String product = null;
251
        try {
252
            product = metaData.getDatabaseProductName();
253
        } catch (SQLException e) {
254
            //do nothing
255
        }
256
        if (product == null){
257
            return null;
258
        }
259
        if (product.toLowerCase().matches("\\.*mysql\\.*")){
260
            return MySQL;
261
        }else if (product.toLowerCase().matches("\\.*hsqldb\\.*")) {
262
            return HSqlDb;
263
        }else if (product.toLowerCase().matches("\\.*oracle\\.*")) {
264
            return Oracle;
265
        }else if (product.toLowerCase().matches("\\.*sybase\\.*")) {
266
            return Sybase;
267
        }else if (product.toLowerCase().matches("\\.*odbc\\.*")) {
268
            return ODBC;
269
        }else if (product.toLowerCase().matches("\\.*postgresql\\.*")) {
270
            return PostgreSQL;
271
        }else if (product.toLowerCase().matches("\\.*sqlserver\\.*")) {
272
            //TODO we need to distinguish versions here once we have sql server 2008 database enum
273
//            metaData.getDatabaseProductVersion()
274
            return SqlServer2005;
275
        }else if (product.toLowerCase().matches("\\.*h2\\.*")) {
276
            return H2;
277
        }
278
        return null;
279
    }
280

  
281
    /**
282
     * Returns the database type evaluating the connection string.
283
     * To retrieves parts of the connection string (e.g. database name),
284
     * get the database type from the enum and call e.g.
285
     * type.getDatabaseType().getDatabaseNameByConnectionString(url);
286
     *
287
     * @param url the connection string
288
     * @return the database type
289
     */
290
    public static DatabaseTypeEnum byConnectionString(String url) {
291
        if (url == null){
292
            return null;
293
        }
294
        for (DatabaseTypeEnum type : values()){
295
            if (url.startsWith(type.getUrl())){
296
                type.getDatabaseType().getDatabaseNameByConnectionString(url);
297
                return type;
298
            }
299
        }
300
        return null;
301
    }
302

  
303

  
304
}
305

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/WrappedCdmDataSource.java
1
/**
2
 *
3
 */
4
package eu.etaxonomy.cdm.database;
5

  
6
import java.io.PrintWriter;
7
import java.net.URI;
8
import java.net.URISyntaxException;
9
import java.sql.Connection;
10
import java.sql.DatabaseMetaData;
11
import java.sql.PreparedStatement;
12
import java.sql.ResultSet;
13
import java.sql.SQLException;
14
import java.sql.SQLFeatureNotSupportedException;
15
import java.util.Map;
16

  
17
import javax.sql.DataSource;
18

  
19
import org.apache.log4j.Logger;
20
import org.hibernate.cache.spi.RegionFactory;
21
import org.springframework.beans.factory.config.BeanDefinition;
22

  
23
import com.mchange.v2.c3p0.ComboPooledDataSource;
24

  
25
import eu.etaxonomy.cdm.config.CdmSourceException;
26
import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName;
27
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
28

  
29
/**
30
 * This class is a wrapper class to wrap an {@link javax.sql.DataSource} to an
31
 * {@link ICdmDataSource}. As the former is a very limited interface it is not possible
32
 * to implement all methods of {@link ICdmDataSource}. However, the aim is
33
 * to implement all those methods which are usually needed to work with a datasource
34
 * which represents a connection to a database such as transaction handling and
35
 * sending queries.
36
 * Those methods which are not supported by this wrapper class will throw an xxx
37
 * exception.
38
 *
39
 *
40
 * @author a.mueller
41
 */
42

  
43
//FIXME this class replicates lots of code in CdmDataSourceBase, we may want to merge it
44
//in a common helper class to avoid redundant code
45
public class WrappedCdmDataSource implements ICdmDataSource {
46
	private static final Logger logger = Logger.getLogger(WrappedCdmDataSource.class);
47

  
48

  
49
	private final DataSource datasource;
50

  
51
	private Connection connection;
52

  
53

  
54
	public WrappedCdmDataSource(DataSource datasource) {
55
		if (datasource == null){
56
			throw new NullPointerException("datasource must not be null for WrappedCdmDataSource");
57
		}
58
		this.datasource = datasource;
59
	}
60

  
61
	@Override
62
	public Connection getConnection() throws SQLException {
63
		Connection existingConnection = getExistingConnection();
64
		if (existingConnection != null){
65
			return existingConnection;
66
		}else{
67
			return datasource.getConnection();
68
		}
69
	}
70

  
71
	public Connection getExistingConnection(){
72
		return this.connection;
73
	}
74

  
75

  
76
	@Override
77
	public Connection getConnection(String username, String password) throws SQLException {
78
		Connection existingConnection = getExistingConnection();
79
		if (existingConnection != null){
80
			return existingConnection;
81
		}else{
82
			return datasource.getConnection(username, password);
83
		}
84
	}
85

  
86
	@Override
87
	public PrintWriter getLogWriter() throws SQLException {
88
		return datasource.getLogWriter();
89
	}
90

  
91
	@Override
92
	public void setLogWriter(PrintWriter out) throws SQLException {
93
		datasource.setLogWriter(out);
94
	}
95

  
96
	@Override
97
	public void setLoginTimeout(int seconds) throws SQLException {
98
		datasource.setLoginTimeout(seconds);
99
	}
100

  
101
	@Override
102
	public int getLoginTimeout() throws SQLException {
103
		return datasource.getLoginTimeout();
104
	}
105

  
106
	@Override
107
	public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
108
		return datasource.getParentLogger();
109
	}
110

  
111
	@Override
112
	public <T> T unwrap(Class<T> iface) throws SQLException {
113
		return datasource.unwrap(iface);
114
	}
115

  
116
	@Override
117
	public boolean isWrapperFor(Class<?> iface) throws SQLException {
118
		return datasource.isWrapperFor(iface);
119
	}
120

  
121
	@Override
122
	public String getName() {
123
		throw new UnsupportedOperationException("getName() not supported by WrappedCdmDataSource");
124
	}
125

  
126
	@Override
127
	public void setName(String name) {
128
		throw new UnsupportedOperationException("setName(String) not supported by WrappedCdmDataSource");
129
	}
130

  
131
	@Override
132
	public String getServer() {
133
		//TODO we may want to use client info from connection here
134
		throw new UnsupportedOperationException("getServer() not supported by WrappedCdmDataSource");
135
	}
136

  
137
	@Override
138
	public void setServer(String server) {
139
		throw new UnsupportedOperationException("setServer() not supported by WrappedCdmDataSource");
140
	}
141

  
142
	@Override
143
	public int getPort() {
144
		//TODO we may want to use client info from connection here
145
		throw new UnsupportedOperationException("getPort() not supported by WrappedCdmDataSource");
146
	}
147

  
148
	@Override
149
	public void setPort(int port) {
150
		throw new UnsupportedOperationException("setPort(int) not supported by WrappedCdmDataSource");
151
	}
152

  
153
	@Override
154
	public NomenclaturalCode getNomenclaturalCode() {
155
		throw new UnsupportedOperationException("getNomenclaturalCode() not supported by WrappedCdmDataSource");
156
	}
157

  
158
	@Override
159
	public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode) {
160
		throw new UnsupportedOperationException("setNomenclaturalCode(nc) not supported by WrappedCdmDataSource");
161
	}
162

  
163
	@Override
164
	public String getDbSchemaVersion() throws CdmSourceException {
165
		try {
166
			return (String)getSingleValue(MetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
167
		} catch (SQLException e) {
168
			throw new CdmSourceException(e.getMessage());
169
		}
170
	}
171

  
172

  
173
	@Override
174
	public boolean isDbEmpty() throws CdmSourceException {
175
		// Any CDM DB should have a schema version
176
		String dbSchemaVersion = getDbSchemaVersion();
177
		return (dbSchemaVersion == null || dbSchemaVersion.equals(""));
178
	}
179

  
180
	@Override
181
	public boolean checkConnection() throws CdmSourceException {
182
		try {
183
			return testConnection();
184
		} catch (ClassNotFoundException e) {
185
			throw new CdmSourceException(e.getMessage());
186
		} catch (SQLException e) {
187
			throw new CdmSourceException(e.getMessage());
188
		}
189
	}
190

  
191
	@Override
192
	public String getConnectionMessage() {
193
		try {
194
			Connection connection = getConnection();
195
			String message = "Connecting to datasource " + connection.getSchema() + ".";
196
			return message;
197
		} catch (SQLException e) {
198
			throw new RuntimeException(e);
199
		}
200
	}
201

  
202
	@Override
203
	public void closeOpenConnections() {
204
	    try {
205
	    	if(connection != null && !connection.isClosed()){
206
                connection.close();
207
                connection = null;
208
            }
209
        } catch (SQLException e) {
210
        	logger.error("Error closing the connection");
211
        }
212
	}
213

  
214
	@Override
215
	public Map<MetaDataPropertyName, String> getMetaDataMap() throws CdmSourceException {
216
		//TODO is it possible/required to build a meta data map here?
217
		throw new UnsupportedOperationException("getMetaDataMap() not supported by WrappedCdmDataSource");
218
	}
219

  
220
	@Override
221
	public BeanDefinition getDatasourceBean() {
222
		//TODO is it possible/required to build a datasource bean here?
223
		throw new UnsupportedOperationException("getDatasourceBean() not supported by WrappedCdmDataSource");
224
	}
225

  
226
	@Override
227
	public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll) {
228
		//TODO is it possible/required to build a properties bean here?
229
		throw new UnsupportedOperationException("getHibernatePropertiesBean() not supported by WrappedCdmDataSource");
230
	}
231

  
232
	@Override
233
	public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll,
234
			Boolean showSql, Boolean formatSql, Boolean registerSearchListener,
235
			Class<? extends RegionFactory> cacheProviderClass) {
236
		//TODO is it possible/required to build a properties bean here?
237
		throw new UnsupportedOperationException("getHibernatePropertiesBean() not supported by WrappedCdmDataSource");
238
	}
239

  
240
	@Override
241
	public String getFilePath() {
242
		throw new UnsupportedOperationException("getFilePath() not supported by WrappedCdmDataSource");
243
	}
244

  
245
	@Override
246
	public H2Mode getMode() {
247
		throw new UnsupportedOperationException("getMode() not supported by WrappedCdmDataSource");
248
	}
249

  
250
	@Override
251
	public String getUsername() {
252
		//TODO maybe this can be implemented by connection meta data
253
		throw new UnsupportedOperationException("getUsername() not supported by WrappedCdmDataSource");
254
	}
255

  
256
	@Override
257
	public String getPassword() {
258
		throw new UnsupportedOperationException("getPassword() not supported by WrappedCdmDataSource");
259
	}
260

  
261
	@Override
262
	public String getDatabase() {
263
	    if(datasource instanceof ComboPooledDataSource) {
264
	      String jdbcUrl = ((ComboPooledDataSource)datasource).getJdbcUrl();
265
	        try {
266
                return getDatabaseFrom(jdbcUrl);
267
            } catch (URISyntaxException e) {
268
                throw new RuntimeException(e);
269
            }
270
	    } else {
271
	        throw new UnsupportedOperationException("getDatabase() not implemented for " + datasource.getClass() + " in WrappedCdmDataSource");
272
	    }
273
	}
274

  
275
    /**
276
     * @param jdbcUrl
277
     * @return
278
     * @throws URISyntaxException
279
     */
280
    private String getDatabaseFrom(String jdbcUrl) throws URISyntaxException {
281
        URI url = new URI(jdbcUrl.substring(5));
282
        return url.getPath().substring(1);
283
    }
284

  
285
	@Override
286
	public void setMode(H2Mode h2Mode) {
287
		throw new UnsupportedOperationException("setMode(H2Mode) not supported by WrappedCdmDataSource");
288
	}
289

  
290
	@Override
291
	public void setUsername(String username) {
292
		throw new UnsupportedOperationException("setUsername(String) not supported by WrappedCdmDataSource");
293
	}
294

  
295
	@Override
296
	public void setPassword(String password) {
297
		throw new UnsupportedOperationException("setPassword(String) not supported by WrappedCdmDataSource");
298
	}
299

  
300
	@Override
301
	public void setDatabase(String database) {
302
		throw new UnsupportedOperationException("setDatabase(String) not supported by WrappedCdmDataSource");
303
	}
304

  
305
	@Override
306
	public DatabaseTypeEnum getDatabaseType() {
307
	    if (this.datasource instanceof ICdmDataSource){
308
	        return ((ICdmDataSource)this.datasource).getDatabaseType();
309
	    }
310

  
311
	    try {
312
            getConnection();
313
        } catch (SQLException e1) {
314
            throw new RuntimeException("SQL Exception while trying to establish connection to datasource");
315
        }
316

  
317
	    String driverName = null;
318
        if (connection != null){
319
            DatabaseMetaData metaData = null;
320
            try {
321
                metaData = connection.getMetaData();
322
            } catch (SQLException e) {
323
                throw new RuntimeException("SQL Exception while trying to read datasource metadata");
324
            }
325

  
326
            try {
327
                driverName = metaData != null ? metaData.getDriverName() : null;
328
            } catch (SQLException e) {
329
                //throw exception at end
330
            }
331
            if (metaData != null){
332
                DatabaseTypeEnum type = DatabaseTypeEnum.byDatabaseMetaData(metaData);
333
                if (type != null){
334
                    return type;
335
                }
336
            }
337
            throw new IllegalStateException("datasource type (MySQL, SQL Server, ...) could not be retrieved from generic datasource");
338

  
339
        }
340
		throw new IllegalStateException("datasource type (MySQL, SQL Server, ...) could not be retrieved from generic datasource");
341
	}
342

  
343
	@Override
344
	public boolean testConnection() throws ClassNotFoundException, SQLException {
345
		return getConnection() != null;
346
	}
347

  
348
	@Override
349
	public ResultSet executeQuery(String query) throws SQLException {
350
		PreparedStatement a = getConnection().prepareStatement(query);
351
		return a.executeQuery();
352
	}
353

  
354
	@Override
355
	public int executeUpdate(String sqlUpdate) throws SQLException {
356
		PreparedStatement a = getConnection().prepareStatement(sqlUpdate);
357
		return a.executeUpdate();
358
	}
359

  
360
	@Override
361
	public void startTransaction() {
362
		try {
363
            Connection connection = getConnection();
364
            this.connection = connection;
365
            connection.setAutoCommit(false);
366
		} catch (SQLException e) {
367
			throw new RuntimeException(e);
368
		}
369
	}
370

  
371
	@Override
372
	public void commitTransaction() throws SQLException {
373
		getConnection().commit();
374
	}
375

  
376
	@Override
377
	public void rollback() throws SQLException {
378
		getConnection().rollback();
379
	}
380

  
381
	@Override
382
	public Object getSingleValue(String query) throws SQLException {
383
		ResultSet rs = this.executeQuery(query);
384
		if (rs.next()){
385
			int count = rs.getMetaData().getColumnCount();
386
			if (count > 0){
387
				return rs.getObject(1);
388
			}
389
		}
390
		return null;
391
	}
392

  
393
	@Override
394
	public DatabaseMetaData getMetaData() {
395
		try {
396
			return getConnection().getMetaData();
397
		} catch (SQLException e) {
398
			throw new RuntimeException(e);
399
		}
400
	}
401
}
1
/**
2
 *
3
 */
4
package eu.etaxonomy.cdm.database;
5

  
6
import java.io.PrintWriter;
7
import java.net.URISyntaxException;
8
import java.sql.Connection;
9
import java.sql.DatabaseMetaData;
10
import java.sql.PreparedStatement;
11
import java.sql.ResultSet;
12
import java.sql.SQLException;
13
import java.sql.SQLFeatureNotSupportedException;
14
import java.util.Map;
15

  
16
import javax.sql.DataSource;
17

  
18
import org.apache.log4j.Logger;
19
import org.hibernate.cache.spi.RegionFactory;
20
import org.springframework.beans.factory.config.BeanDefinition;
21

  
22
import com.mchange.v2.c3p0.ComboPooledDataSource;
23

  
24
import eu.etaxonomy.cdm.config.CdmSourceException;
25
import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName;
26
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
27

  
28
/**
29
 * This class is a wrapper class to wrap an {@link javax.sql.DataSource} to an
30
 * {@link ICdmDataSource}. As the former is a very limited interface it is not possible
31
 * to implement all methods of {@link ICdmDataSource}. However, the aim is
32
 * to implement all those methods which are usually needed to work with a datasource
33
 * which represents a connection to a database such as transaction handling and
34
 * sending queries.
35
 * Those methods which are not supported by this wrapper class will throw an xxx
36
 * exception.
37
 *
38
 *
39
 * @author a.mueller
40
 */
41

  
42
//FIXME this class replicates lots of code in CdmDataSourceBase, we may want to merge it
43
//in a common helper class to avoid redundant code
44
public class WrappedCdmDataSource implements ICdmDataSource {
45
	private static final Logger logger = Logger.getLogger(WrappedCdmDataSource.class);
46

  
47

  
48
	private final DataSource datasource;
49

  
50
	private Connection connection;
51

  
52

  
53
	public WrappedCdmDataSource(DataSource datasource) {
54
		if (datasource == null){
55
			throw new NullPointerException("datasource must not be null for WrappedCdmDataSource");
56
		}
57
		this.datasource = datasource;
58
	}
59

  
60
	@Override
61
	public Connection getConnection() throws SQLException {
62
		Connection existingConnection = getExistingConnection();
63
		if (existingConnection != null){
64
			return existingConnection;
65
		}else{
66
			return datasource.getConnection();
67
		}
68
	}
69

  
70
	public Connection getExistingConnection(){
71
		return this.connection;
72
	}
73

  
74

  
75
	@Override
76
	public Connection getConnection(String username, String password) throws SQLException {
77
		Connection existingConnection = getExistingConnection();
78
		if (existingConnection != null){
79
			return existingConnection;
80
		}else{
81
			return datasource.getConnection(username, password);
82
		}
83
	}
84

  
85
	@Override
86
	public PrintWriter getLogWriter() throws SQLException {
87
		return datasource.getLogWriter();
88
	}
89

  
90
	@Override
91
	public void setLogWriter(PrintWriter out) throws SQLException {
92
		datasource.setLogWriter(out);
93
	}
94

  
95
	@Override
96
	public void setLoginTimeout(int seconds) throws SQLException {
97
		datasource.setLoginTimeout(seconds);
98
	}
99

  
100
	@Override
101
	public int getLoginTimeout() throws SQLException {
102
		return datasource.getLoginTimeout();
103
	}
104

  
105
	@Override
106
	public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
107
		return datasource.getParentLogger();
108
	}
109

  
110
	@Override
111
	public <T> T unwrap(Class<T> iface) throws SQLException {
112
		return datasource.unwrap(iface);
113
	}
114

  
115
	@Override
116
	public boolean isWrapperFor(Class<?> iface) throws SQLException {
117
		return datasource.isWrapperFor(iface);
118
	}
119

  
120
	@Override
121
	public String getName() {
122
		throw new UnsupportedOperationException("getName() not supported by WrappedCdmDataSource");
123
	}
124

  
125
	@Override
126
	public void setName(String name) {
127
		throw new UnsupportedOperationException("setName(String) not supported by WrappedCdmDataSource");
128
	}
129

  
130
	@Override
131
	public String getServer() {
132
		//TODO we may want to use client info from connection here
133
		throw new UnsupportedOperationException("getServer() not supported by WrappedCdmDataSource");
134
	}
135

  
136
	@Override
137
	public void setServer(String server) {
138
		throw new UnsupportedOperationException("setServer() not supported by WrappedCdmDataSource");
139
	}
140

  
141
	@Override
142
	public int getPort() {
143
		//TODO we may want to use client info from connection here
144
		throw new UnsupportedOperationException("getPort() not supported by WrappedCdmDataSource");
145
	}
146

  
147
	@Override
148
	public void setPort(int port) {
149
		throw new UnsupportedOperationException("setPort(int) not supported by WrappedCdmDataSource");
150
	}
151

  
152
	@Override
153
	public NomenclaturalCode getNomenclaturalCode() {
154
		throw new UnsupportedOperationException("getNomenclaturalCode() not supported by WrappedCdmDataSource");
155
	}
156

  
157
	@Override
158
	public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode) {
159
		throw new UnsupportedOperationException("setNomenclaturalCode(nc) not supported by WrappedCdmDataSource");
160
	}
161

  
162
	@Override
163
	public String getDbSchemaVersion() throws CdmSourceException {
164
		try {
165
			return (String)getSingleValue(MetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
166
		} catch (SQLException e) {
167
			throw new CdmSourceException(e.getMessage());
168
		}
169
	}
170

  
171

  
172
	@Override
173
	public boolean isDbEmpty() throws CdmSourceException {
174
		// Any CDM DB should have a schema version
175
		String dbSchemaVersion = getDbSchemaVersion();
176
		return (dbSchemaVersion == null || dbSchemaVersion.equals(""));
177
	}
178

  
179
	@Override
180
	public boolean checkConnection() throws CdmSourceException {
181
		try {
182
			return testConnection();
183
		} catch (ClassNotFoundException e) {
184
			throw new CdmSourceException(e.getMessage());
185
		} catch (SQLException e) {
186
			throw new CdmSourceException(e.getMessage());
187
		}
188
	}
189

  
190
	@Override
191
	public String getConnectionMessage() {
192
		try {
193
			Connection connection = getConnection();
194
			String message = "Connecting to datasource " + connection.getSchema() + ".";
195
			return message;
196
		} catch (SQLException e) {
197
			throw new RuntimeException(e);
198
		}
199
	}
200

  
201
	@Override
202
	public void closeOpenConnections() {
203
	    try {
204
	    	if(connection != null && !connection.isClosed()){
205
                connection.close();
206
                connection = null;
207
            }
208
        } catch (SQLException e) {
209
        	logger.error("Error closing the connection");
210
        }
211
	}
212

  
213
	@Override
214
	public Map<MetaDataPropertyName, String> getMetaDataMap() throws CdmSourceException {
215
		//TODO is it possible/required to build a meta data map here?
216
		throw new UnsupportedOperationException("getMetaDataMap() not supported by WrappedCdmDataSource");
217
	}
218

  
219
	@Override
220
	public BeanDefinition getDatasourceBean() {
221
		//TODO is it possible/required to build a datasource bean here?
222
		throw new UnsupportedOperationException("getDatasourceBean() not supported by WrappedCdmDataSource");
223
	}
224

  
225
	@Override
226
	public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll) {
227
		//TODO is it possible/required to build a properties bean here?
228
		throw new UnsupportedOperationException("getHibernatePropertiesBean() not supported by WrappedCdmDataSource");
229
	}
230

  
231
	@Override
232
	public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll,
233
			Boolean showSql, Boolean formatSql, Boolean registerSearchListener,
234
			Class<? extends RegionFactory> cacheProviderClass) {
235
		//TODO is it possible/required to build a properties bean here?
236
		throw new UnsupportedOperationException("getHibernatePropertiesBean() not supported by WrappedCdmDataSource");
237
	}
238

  
239
	@Override
240
	public String getFilePath() {
241
		throw new UnsupportedOperationException("getFilePath() not supported by WrappedCdmDataSource");
242
	}
243

  
244
	@Override
245
	public H2Mode getMode() {
246
		throw new UnsupportedOperationException("getMode() not supported by WrappedCdmDataSource");
247
	}
248

  
249
	@Override
250
	public String getUsername() {
251
		//TODO maybe this can be implemented by connection meta data
252
		throw new UnsupportedOperationException("getUsername() not supported by WrappedCdmDataSource");
253
	}
254

  
255
	@Override
256
	public String getPassword() {
257
		throw new UnsupportedOperationException("getPassword() not supported by WrappedCdmDataSource");
258
	}
259

  
260
	@Override
261
	public String getDatabase() {
262
	    if(datasource instanceof ComboPooledDataSource) {
263
	      String jdbcUrl = ((ComboPooledDataSource)datasource).getJdbcUrl();
264
	        try {
265
                return getDatabaseFrom(jdbcUrl);
266
            } catch (URISyntaxException e) {
267
                throw new RuntimeException(e);
268
            }
269
	    } else {
270
	        throw new UnsupportedOperationException("getDatabase() not implemented for " + datasource.getClass() + " in WrappedCdmDataSource");
271
	    }
272
	}
273

  
274
    /**
275
     * @param dbType
276
     * @param jdbcUrl
277
     * @return
278
     * @throws URISyntaxException
279
     */
280
    private String getDatabaseFrom(String jdbcUrl) throws URISyntaxException {
281
        DatabaseTypeEnum type = DatabaseTypeEnum.byConnectionString(jdbcUrl);
282
        if (type == null){
283
            return null;
284
        }else{
285
            String dbName = type.getDatabaseType().getDatabaseNameByConnectionString(jdbcUrl);
286
            return dbName;
287
        }
288
    }
289

  
290
	@Override
291
	public void setMode(H2Mode h2Mode) {
292
		throw new UnsupportedOperationException("setMode(H2Mode) not supported by WrappedCdmDataSource");
293
	}
294

  
295
	@Override
296
	public void setUsername(String username) {
297
		throw new UnsupportedOperationException("setUsername(String) not supported by WrappedCdmDataSource");
298
	}
299

  
300
	@Override
301
	public void setPassword(String password) {
302
		throw new UnsupportedOperationException("setPassword(String) not supported by WrappedCdmDataSource");
303
	}
304

  
305
	@Override
306
	public void setDatabase(String database) {
307
		throw new UnsupportedOperationException("setDatabase(String) not supported by WrappedCdmDataSource");
308
	}
309

  
310
	@Override
311
	public DatabaseTypeEnum getDatabaseType() {
312
	    if (this.datasource instanceof ICdmDataSource){
313
	        return ((ICdmDataSource)this.datasource).getDatabaseType();
314
	    }
315

  
316
	    try {
317
            getConnection();
318
        } catch (SQLException e1) {
319
            throw new RuntimeException("SQL Exception while trying to establish connection to datasource");
320
        }
321

  
322
	    String driverName = null;
323
        if (connection != null){
324
            DatabaseMetaData metaData = null;
325
            try {
326
                metaData = connection.getMetaData();
327
            } catch (SQLException e) {
328
                throw new RuntimeException("SQL Exception while trying to read datasource metadata");
329
            }
330

  
331
            try {
332
                driverName = metaData != null ? metaData.getDriverName() : null;
333
            } catch (SQLException e) {
334
                //throw exception at end
335
            }
336
            if (metaData != null){
337
                DatabaseTypeEnum type = DatabaseTypeEnum.byDatabaseMetaData(metaData);
338
                if (type != null){
339
                    return type;
340
                }
341
            }
342
            throw new IllegalStateException("datasource type (MySQL, SQL Server, ...) could not be retrieved from generic datasource");
343

  
344
        }
345
		throw new IllegalStateException("datasource type (MySQL, SQL Server, ...) could not be retrieved from generic datasource");
346
	}
347

  
348
	@Override
349
	public boolean testConnection() throws ClassNotFoundException, SQLException {
350
		return getConnection() != null;
351
	}
352

  
353
	@Override
354
	public ResultSet executeQuery(String query) throws SQLException {
355
		PreparedStatement a = getConnection().prepareStatement(query);
356
		return a.executeQuery();
357
	}
358

  
359
	@Override
360
	public int executeUpdate(String sqlUpdate) throws SQLException {
361
		PreparedStatement a = getConnection().prepareStatement(sqlUpdate);
362
		return a.executeUpdate();
363
	}
364

  
365
	@Override
366
	public void startTransaction() {
367
		try {
368
            Connection connection = getConnection();
369
            this.connection = connection;
370
            connection.setAutoCommit(false);
371
		} catch (SQLException e) {
372
			throw new RuntimeException(e);
373
		}
374
	}
375

  
376
	@Override
377
	public void commitTransaction() throws SQLException {
378
		getConnection().commit();
379
	}
380

  
381
	@Override
382
	public void rollback() throws SQLException {
383
		getConnection().rollback();
384
	}
385

  
386
	@Override
387
	public Object getSingleValue(String query) throws SQLException {
388
		ResultSet rs = this.executeQuery(query);
389
		if (rs.next()){
390
			int count = rs.getMetaData().getColumnCount();
391
			if (count > 0){
392
				return rs.getObject(1);
393
			}
394
		}
395
		return null;
396
	}
397

  
398
	@Override
399
	public DatabaseMetaData getMetaData() {
400
		try {
401
			return getConnection().getMetaData();
402
		} catch (SQLException e) {
403
			throw new RuntimeException(e);
404
		}
405
	}
406
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/database/DatabaseEnumTest.java
1
/**
2
* Copyright (C) 2009 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 static org.junit.Assert.*;
13

  
14
import java.util.List;
15

  
16
import org.apache.log4j.Logger;
17

  
18
import org.junit.Before;
19
import org.junit.BeforeClass;
20
import org.junit.Test;
21

  
22

  
23
/**
24
 * @author a.mueller
25
 *
26
 */
27
public class DatabaseEnumTest {
28
	@SuppressWarnings("unused")
29
	private static final Logger logger = Logger.getLogger(DatabaseEnumTest.class);
30
	private static DatabaseTypeEnum dbEnum;
31
	private static DatabaseTypeEnum dbEnumSql2005;
32
	
33
	/**
34
	 * @throws java.lang.Exception
35
	 */
36
	@BeforeClass
37
	public static void setUpBeforeClass() throws Exception {
38
		dbEnum = DatabaseTypeEnum.MySQL;
39
		dbEnumSql2005 = DatabaseTypeEnum.SqlServer2005;
40
	}
41

  
42

  
43
	/**
44
	 * @throws java.lang.Exception
45
	 */
46
	@Before
47
	public void setUp() throws Exception {
48
	}
49

  
50
	/**
51
	 * Test method for {@link eu.etaxonomy.cdm.database.DatabaseTypeEnum#getName()}.
52
	 */
53
	@Test
54
	public void testGetName() {
55
		assertEquals("MySQL", DatabaseEnumTest.dbEnum.getName());
56
	}
57

  
58
	/**
59
	 * Test method for {@link eu.etaxonomy.cdm.database.DatabaseTypeEnum#getDriverClassName()}.
60
	 */
61
	@Test
62
	public void testGetDriverClassName() {
63
		assertEquals("com.mysql.jdbc.Driver", DatabaseEnumTest.dbEnum.getDriverClassName());
64
	}
65

  
66
	/**
67
	 * Test method for {@link eu.etaxonomy.cdm.database.DatabaseTypeEnum#getUrl()}.
68
	 */
69
	@Test
70
	public void testGetUrl() {
71
		assertEquals("jdbc:mysql://", DatabaseEnumTest.dbEnum.getUrl());
72
	}
73

  
74
	/**
75
	 * Test method for {@link eu.etaxonomy.cdm.database.DatabaseTypeEnum#getDefaultPort()}.
76
	 */
77
	@Test
78
	public void testGetDefaultPort() {
79
		assertEquals(9001, DatabaseTypeEnum.HSqlDb.getDefaultPort());
80
	}
81

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)