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 eu.etaxonomy.cdm.database.ICdmDataSource;
|
13
|
|
14
|
|
15
|
/**
|
16
|
* @author a.mueller
|
17
|
*
|
18
|
*/
|
19
|
public class MySQLDatabaseType extends DatabaseTypeBase {
|
20
|
|
21
|
//typeName
|
22
|
protected String typeName = "MySQL";
|
23
|
|
24
|
//class
|
25
|
protected String classString = "com.mysql.jdbc.Driver";
|
26
|
|
27
|
//url
|
28
|
protected String urlString = "jdbc:mysql://";
|
29
|
|
30
|
//port
|
31
|
private int defaultPort = 3306;
|
32
|
|
33
|
private static String dbSeparator = "/";
|
34
|
|
35
|
//hibernate dialect
|
36
|
//private String hibernateDialect = "MySQLInnoDBUtf8Dialect";
|
37
|
private String hibernateDialect = "MySQL5MyISAMUtf8Dialect";
|
38
|
|
39
|
//connection String
|
40
|
public String getConnectionString(ICdmDataSource ds, int port){
|
41
|
return urlString + ds.getServer() + ":" + port + dbSeparator + ds.getDatabase() + "?useUnicode=true&characterEncoding=utf8" + "&zeroDateTimeBehavior=convertToNull";
|
42
|
//return urlString + ds.getServer() + ":" + port + "/" + ds.getDatabase() + "?useUnicode=true&characterEncoding=utf8&connectionCollation=utf8_general_ci&characterSetResults=utf8&jdbcCompliantTruncation=false";
|
43
|
}
|
44
|
|
45
|
/* (non-Javadoc)
|
46
|
* @see eu.etaxonomy.cdm.database.types.DatabaseTypeBase#getServerNameByConnectionString(java.lang.String)
|
47
|
*/
|
48
|
@Override
|
49
|
public String getDatabaseNameByConnectionString(String connectionString){
|
50
|
String result;
|
51
|
result = getDatabasePartOfConnectionString(connectionString, dbSeparator);
|
52
|
int posParams = result.indexOf("?");
|
53
|
if (posParams != -1){
|
54
|
result = result.substring(0, posParams);
|
55
|
}
|
56
|
return result;
|
57
|
}
|
58
|
|
59
|
/**
|
60
|
* Constructor
|
61
|
*/
|
62
|
public MySQLDatabaseType() {
|
63
|
init (typeName, classString, urlString, defaultPort, hibernateDialect );
|
64
|
}
|
65
|
|
66
|
|
67
|
}
|