使用JDBC与oracle database做connection
以下是source code:
String driver = "oracle.jdbc.driver.OracleDriver";
Class.forName(driver).newInstance();
pass= EncryptionUtils.decrypt(pass);
PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();
pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
pds.setURL("jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=ON)(ADDRESS_LIST="
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.60)(PORT=1521))"
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.61)(PORT=1521)))"
+ "(CONNECT_DATA=(SERVICE_NAME=test)))");
pds.setUser(user);
pds.setPassword(pass);
pds.setMinPoolSize(10);
pds.setMaxPoolSize(20);
pds.setFastConnectionFailoverEnabled(true);
Connection conn = pds.getConnection();
在取得connection时产生error:
java.lang.NullPointerException
请问是url上有什么错误或是要注意哪些部份吗?