1 /*******************************************************************************
2 * All rights reserved. This program and the accompanying materials
3 * are made available under the terms of the GNU Lesser Public License v2.1
4 * which accompanies this distribution, and is available at
5 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
8 * hangum - initial API and implementation
9 ******************************************************************************/
10 package com
.hangum
.tadpole
.engine
.utils
;
12 import org
.apache
.commons
.lang
.StringUtils
;
14 import com
.hangum
.tadpole
.commons
.libs
.core
.define
.PublicTadpoleDefine
;
15 import com
.hangum
.tadpole
.engine
.define
.DBDefine
;
16 import com
.hangum
.tadpole
.engine
.query
.dao
.system
.UserDBDAO
;
19 * make jdbc connection string tuils
24 public class MakeJDBCConnectionStringUtil
{
32 public static String
makeConnectionUrl(final UserDBDAO userDB
) {
35 if(userDB
.getDBDefine() == DBDefine
.MYSQL_DEFAULT
) {
36 String selectLocale
= StringUtils
.trimToEmpty(userDB
.getLocale());
37 if(selectLocale
.equals("") || DBLocaleUtils
.NONE_TXT
.equals(selectLocale
)) {
38 dbUrl
= getPueURL(userDB
.getDBDefine().getDB_URL_INFO(), userDB
);
39 if(!"".equals(userDB
.getUrl_user_parameter())) {
40 dbUrl
+= "?" + userDB
.getUrl_user_parameter();
44 dbUrl
= getPueURL(userDB
.getDBDefine().getDB_URL_INFO(), userDB
) + "?useUnicode=false&characterEncoding=" + selectLocale
;
45 if(!"".equals(userDB
.getUrl_user_parameter())) {
46 dbUrl
+= "&" + userDB
.getUrl_user_parameter();
49 } else if(userDB
.getDBDefine() == DBDefine
.ORACLE_DEFAULT
) {
50 if(userDB
.getExt1().equals("SID")) {
51 // return "jdbc:oracle:thin:@%s:%s:%s";
52 dbUrl
= getPueURL(userDB
.getDBDefine().getDB_URL_INFO(), userDB
);
53 } else if(userDB
.getExt1().equals("Service Name")) {
54 dbUrl
= getPueURL("jdbc:oracle:thin:@//%s:%s/%s", userDB
);
57 if(!"".equals(userDB
.getUrl_user_parameter())) {
58 dbUrl
+= "?" + userDB
.getUrl_user_parameter();
60 } else if(userDB
.getDBDefine() == DBDefine
.MONGODB_DEFAULT
) {
61 dbUrl
= getPueURL(userDB
.getDBDefine().getDB_URL_INFO(), userDB
);
62 if(!"".equals(userDB
.getUrl_user_parameter())) {
63 dbUrl
+= "/?" + userDB
.getUrl_user_parameter();
65 } else if(userDB
.getDBDefine() == DBDefine
.ALTIBASE_DEFAULT
) {
66 String selectLocale
= StringUtils
.trimToEmpty(userDB
.getLocale());
68 if(selectLocale
.equals("") || DBLocaleUtils
.NONE_TXT
.equals(selectLocale
)) {
69 dbUrl
= getPueURL(userDB
.getDBDefine().getDB_URL_INFO(), userDB
);
71 if(!"".equals(userDB
.getUrl_user_parameter())) {
72 dbUrl
+= "?" + userDB
.getUrl_user_parameter();
75 dbUrl
= getPueURL(userDB
.getDBDefine().getDB_URL_INFO(), userDB
) + "?charset=" + selectLocale
;
77 if(!"".equals(userDB
.getUrl_user_parameter())) {
78 dbUrl
+= "&" + userDB
.getUrl_user_parameter();
81 } else if(userDB
.getDBDefine() == DBDefine
.POSTGRE_DEFAULT
) {
82 dbUrl
= getPueURL(userDB
.getDBDefine().getDB_URL_INFO(), userDB
);
83 if(PublicTadpoleDefine
.YES_NO
.YES
.name().equals(userDB
.getExt1())) {
84 dbUrl
+= "?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"; //$NON-NLS-1$
86 if(!"".equals(userDB
.getUrl_user_parameter())) { //$NON-NLS-1$
87 dbUrl
+= "&" + userDB
.getUrl_user_parameter(); //$NON-NLS-1$
90 if(!"".equals(userDB
.getUrl_user_parameter())) { //$NON-NLS-1$
91 dbUrl
+= "?" + userDB
.getUrl_user_parameter(); //$NON-NLS-1$
100 private static String
getPueURL(String strTempURL
, final UserDBDAO userDB
) {
101 return String
.format(
103 StringUtils
.trimToEmpty(userDB
.getHost()),
104 StringUtils
.trimToEmpty(userDB
.getPort()),
105 StringUtils
.trimToEmpty(userDB
.getDb())