我有以下代码来连接到oracle数据库。但是使用hikaricp我得到了例外。
java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
代码:
private static HikariDataSource dataSource() {
final HikariDataSource hikariDataSource = new HikariDataSource();
hikariDataSource.setMaximumPoolSize(100);
hikariDataSource.setMinimumIdle(10);
hikariDataSource.setDataSourceClassName("oracle.jdbc.pool.OracleDataSource");
Properties properties = new Properties();
properties.put("user", "user");
properties.put("password", "pass");
properties.put("databaseName", "XE");
properties.put("serverName", "192.168.21.13");
properties.put("portNumber", "1521");
hikariDataSource.setDataSourceProperties(properties);
//Additionally I am setting connection test query and max life time also
return hikariDataSource;
}
完整的堆栈跟踪是
Exception in thread "main" java.lang.RuntimeException: Fail-fast during pool initialization
at com.zaxxer.hikari.pool.HikariPool.fillPool(HikariPool.java:499)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:162)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:113)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:102)
at java.lang.reflect.Method.invoke(Method.java:597)
Caused by: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
at oracle.jdbc.pool.OracleDataSource.makeURL(OracleDataSource.java:1277)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:185)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:157)
at com.zaxxer.hikari.pool.HikariPool.addConnection(HikariPool.java:418)
at com.zaxxer.hikari.pool.HikariPool.fillPool(HikariPool.java:498)
... 11 more
如何建立成功的游泳池?我正在使用oracle jar http://download.oracle.com/otn/utilities_drivers/jdbc/111070/ojdbc6.jar 而jdk是1.6。对于java 6,Hikaricp版本为2.2.5。
答案 0 :(得分:7)
尝试将驱动程序类型设置为thin
。
properties.put("driverType", "thin");