日期:2014-05-16 浏览次数:20471 次
public static Connection getConnForOracleLive(String username,String password) throws Exception{ //驱动名 String driverName = "oracle.jdbc.driver.OracleDriver"; //连接服务器和数据库名 String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=werprac3-vip.ttmtech.com.hk)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.30.254.36)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=werprac1-vip.ttmtech.com.hk)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.30.254.38)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=werprac2-vip.ttmtech.com.hk)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.30.254.37)(PORT=1521)))(LOAD_BALANCE=YES)(FAILOVER=ON)(CONNECT_DATA=(SERVICE_NAME=PRD1)))"; Connection conn = null; //加载驱动 Class.forName(driverName); //获取连接 conn = DriverManager.getConnection(url, username, password); System.out.println("获取oracleLive连接成功!"); return conn; } }