java,php,asp.net,linux,javascript,mysql,mssql,oracle,编程

java的常用函数3

转载请注明:http://www.pmjava.com/Article/ShowInfo.asp?ID=56545

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);
    }


posted on 2009-06-10 21:01 rrong_m 阅读(121) 评论(0)  编辑  收藏 所属分类: java

<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

常用链接

随笔档案

文章分类

文章档案

java编程

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜