Invalid Oracle URL: OracleDataSource.makeURL

I try to connect to the local oracle database, but I get this cryptic error message: Invalid Oracle URL specified: OracleDataSource.makeURL .

I am sure that this is due to an error with the database connection parameters that I am transmitting, but actually this error message does not help me in any way. Any hints that I'm doing wrong will be greatly appreciated.

FYI: The code used to connect below, with the exception of hard-coded strings, is what is used in our production environment and works there.

 OracleDataSource dataSource = new OracleDataSource(); dataSource.setServerName("localhost"); dataSource.setUser(userName); dataSource.setPassword(password); dataSource.setDatabaseName("orcl"); return dataSource.getConnection(); 
+4
source share
2 answers

Also, after adding the following two lines to the code that created the connection, it worked.

 dataSource.setPortNumber(1521); dataSource.setDriverType("thin"); 

I don’t understand why we didn’t have this problem before, but this may have something to do with my local installation. My biggest beef is with an error message giving no details on what is wrong.

+11
source

if you use setUrl (or if your container looks like an old fish)

make sure you use the correct syntax

JDBC: oracle: thin: @localhost: one thousand five hundred twenty one: s.i.d.

or

JDBC: oracle: thin: @localhost: 1521 \ SERVICENAME

The datasource class tries to parse it and gives a cryptic error if the syntax has problems.

+2
source

All Articles