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