Project

General

Profile

Download (1.91 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.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
}
(2-2/15)