public static String getURLByDBInfo(DBInfo dbInfo)
{
String url = "";
if(dbInfo.getDbType() != null)
if(dbInfo.getDbType().equals("SQLSERVER"))
url = (new StringBuilder("jdbc:microsoft:sqlserver://")).append(dbInfo.getDbHost()).append(":").append(dbInfo.getDbPort()).append(";DatabaseName=").append(dbInfo.getDbSID()).toString();
else
if(dbInfo.getDbType().equals("ORACLE"))
url = (new StringBuilder("jdbc:oracle:thin:@")).append(dbInfo.getDbHost()).append(":").append(dbInfo.getDbPort()).append(":").append(dbInfo.getDbSID()).toString();
else
if(dbInfo.getDbType().equals("ORACLE_DSP"))
url = (new StringBuilder("jdbc:dsp@")).append(dbInfo.getDbHost()).append(":").append(dbInfo.getDbPort()).append("/").append(dbInfo.getDbSID()).append("/").append(dbInfo.getNamespace()).toString();
else
if(dbInfo.getDbType().equals("SYBASE"))
url = "jdbc:sybase:Tds:...";
else
url = "sun.jdbc.odbc.JdbcOdbcDriver";
return url;
}
/**
* 全角字符转半角字符
*
* @param QJStr
* @return String
*/
public static final String QJToBJChange(String QJStr)
{
char[] chr = QJStr.toCharArray();
String str = "";
for (int i = 0; i < chr.length; i++)
{
chr[i] = (char) ((int) chr[i] - 65248);
str += chr[i];
}
return str;
}
**
* 去掉字符串中重复的子字符串
*
* @param str
* @return String
*/
private static String removeSameString(String str)
{
Set<String> mLinkedSet = new LinkedHashSet<String>();
String[] strArray = str.split(" ");
StringBuffer sb = new StringBuffer();
for (int i = 0; i < strArray.length; i++)
{
if (!mLinkedSet.contains(strArray[i]))
{
mLinkedSet.add(strArray[i]);
sb.append(strArray[i] + " ");
}
}
System.out.println(mLinkedSet);
return sb.toString().substring(0, sb.toString().length() - 1);
}
|