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
|
package eu.etaxonomy.cdm.database.types;
|
10
|
|
11
|
import org.hibernate.dialect.DB2Dialect;
|
12
|
import org.hibernate.dialect.Dialect;
|
13
|
|
14
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
15
|
|
16
|
|
17
|
/**
|
18
|
* !! UNTESTED !!
|
19
|
* Db2 in use with Universal Driver (db2jcc.jar)
|
20
|
*
|
21
|
* @author a.mueller
|
22
|
*
|
23
|
*/
|
24
|
public class Db2DatabaseType extends DatabaseTypeBase {
|
25
|
|
26
|
//typeName
|
27
|
protected String typeName = "DB2 Universal";
|
28
|
//class
|
29
|
protected String classString = "com.ibm.db2.jcc.DB2Driver";
|
30
|
//protected String classString = "COM.ibm.db2.jdbc.app.DB2Driver";
|
31
|
//protected String classString = "COM.ibm.db2.jdbc.net.DB2Driver";
|
32
|
|
33
|
//url
|
34
|
protected String urlString = "jdbc:db2://";
|
35
|
//port
|
36
|
private int defaultPort = 50000;
|
37
|
//hibernate dialect
|
38
|
private Dialect hibernateDialect = new DB2Dialect();
|
39
|
|
40
|
private static String dbSeparator = "/";
|
41
|
|
42
|
//connection String
|
43
|
public String getConnectionString(ICdmDataSource ds, int port){
|
44
|
|
45
|
return urlString + ds.getServer() + ":" + port + dbSeparator + ds.getDatabase();
|
46
|
}
|
47
|
|
48
|
public String getDatabaseNameByConnectionString(String connectionString){
|
49
|
String result;
|
50
|
result = getDatabasePartOfConnectionString(connectionString,dbSeparator);
|
51
|
//TODO
|
52
|
// int posParams = result.indexOf("?");
|
53
|
// if (posParams != -1){
|
54
|
// result = result.substring(0, posParams);
|
55
|
// }
|
56
|
return result;
|
57
|
}
|
58
|
|
59
|
public Db2DatabaseType() {
|
60
|
init (typeName, classString, urlString, defaultPort, hibernateDialect );
|
61
|
}
|
62
|
}
|