Project

General

Profile

« Previous | Next » 

Revision 8b32a3ce

Added by Andreas Müller almost 2 years ago

cleanup

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/DbcpSaveDataSource.java
15 15

  
16 16
import org.apache.commons.dbcp.BasicDataSource;
17 17
import org.apache.commons.pool.impl.GenericObjectPool;
18
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
18
import org.apache.logging.log4j.LogManager;
19
import org.apache.logging.log4j.Logger;
19 20

  
20 21
/**
21 22
 * @author n.hoffmann
22 23
 * @since Sep 22, 2009
23 24
 */
24 25
public class DbcpSaveDataSource extends BasicDataSource {
25
	@SuppressWarnings("unused")
26
	private static final Logger logger = LogManager.getLogger(DbcpSaveDataSource.class);
26

  
27
    @SuppressWarnings("unused")
28
	private static final Logger logger = LogManager.getLogger();
27 29

  
28 30
	/* FIXME This is a workaround to solve a problem with dbcp connection pooling.
29 31
	 * Remove this when dbcp connection pool gets configured correctly
30
	 *
31
	 * (non-Javadoc)
32
	 * @see org.apache.commons.dbcp.BasicDataSource#createDataSource()
33 32
	 */
34 33
	@Override
35 34
	protected synchronized DataSource createDataSource() throws SQLException {
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/types/DatabaseTypeBase.java
20 20

  
21 21
/**
22 22
 * @author a.mueller
23
 *
24 23
 */
25 24
abstract class DatabaseTypeBase implements IDatabaseType {
26 25
	private static final Logger logger = LogManager.getLogger(DatabaseTypeBase.class);
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/types/Db2DatabaseType.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.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
}

Also available in: Unified diff