Error connecting Oracle on localhost: Could not get JDBC Connection ?
-
Hi everyone, I am trying to connect Oracle database from my web application using Eclipse. But I got the error:org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; I used below code:
public static void initDB(){
try {
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName("oracle.jdbc.driver.OracleDriver");
ds.setUrl("jdbc:oracle:thin:@localhost:1521:xe");
ds.setUsername("mybank");
ds.setPassword("123456");jdbcTemplate = new JdbcTemplate(ds); // throw exceptiong after this line isConnected = true; initSystemPros(); } catch (Exception e) { System.err.println("Cannot connect to DataBase"); isConnected = false; } }
I tried to use SQL Developer to create a connection using above settings and successful. Do you know what is wrong ? Thanks and regards, Tai
-
Hi everyone, I am trying to connect Oracle database from my web application using Eclipse. But I got the error:org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; I used below code:
public static void initDB(){
try {
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName("oracle.jdbc.driver.OracleDriver");
ds.setUrl("jdbc:oracle:thin:@localhost:1521:xe");
ds.setUsername("mybank");
ds.setPassword("123456");jdbcTemplate = new JdbcTemplate(ds); // throw exceptiong after this line isConnected = true; initSystemPros(); } catch (Exception e) { System.err.println("Cannot connect to DataBase"); isConnected = false; } }
I tried to use SQL Developer to create a connection using above settings and successful. Do you know what is wrong ? Thanks and regards, Tai
-
Hi everyone, I am trying to connect Oracle database from my web application using Eclipse. But I got the error:org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; I used below code:
public static void initDB(){
try {
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName("oracle.jdbc.driver.OracleDriver");
ds.setUrl("jdbc:oracle:thin:@localhost:1521:xe");
ds.setUsername("mybank");
ds.setPassword("123456");jdbcTemplate = new JdbcTemplate(ds); // throw exceptiong after this line isConnected = true; initSystemPros(); } catch (Exception e) { System.err.println("Cannot connect to DataBase"); isConnected = false; } }
I tried to use SQL Developer to create a connection using above settings and successful. Do you know what is wrong ? Thanks and regards, Tai
Be sure that `xe` is your `Service Name`. If the connection is successfull but you have this exception `SQLNestedException: Cannot create PoolableConnectionFactory (Io exception: The Network Adapter could not establish the connection) at` " you must have an incompatible version of JDBC, install the correct one: http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-10201-088211.html