Java – invalid Oracle URL specified: oracledatasource makeURL

I am trying to connect to the local Oracle database, but I receive this mysterious error message:

I'm sure this is due to an error in the database connection parameters I passed, but in fact, this error message doesn't help me Any hint of my mistake will be appreciated

For reference only: the code for connection is as follows, except for hard coded strings, which are used in our production environment and work there

OracleDataSource dataSource = new OracleDataSource();
 dataSource.setServerName("localhost");
 dataSource.setUser(userName);
 dataSource.setPassword(password);
 dataSource.setDatabaseName("orcl");
return dataSource.getConnection();

Solution

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

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

I don't understand why we didn't have this problem before, but it may be related to my local installation My biggest advantage is that the error message does not provide any details about the error

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>