Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How do I successfully pass username/password to jdbc url?

beckyjmcdJan 16 2019 — edited Jan 28 2019

I am having some difficulty creating a jdbc connection when I try to specify the username/password in the URL.  For example, if I have the following code in a try/catch:

String url = "jdbc:oracle:thin:jts_db_user/********@gpdv6.sandia.gov:1525/gpdv6..world";

Connection conn = DriverManager.getConnection(url);

I get an exception:  "java.sql.SQLException: Invalid Oracle URL specified"

However, if I omit the user/name and password from the URL and pass it to the "getConnection" method as follows:

String url = "jdbc:oracle:thin:@gpdv6.sandia.gov:1525/gpdv6..world";

Connection conn = DriverManager.getConnection(url, "jts_db_user", "*******");

I get a valid connection object (and can execute SQL commands against it).

I am using "ojdbc8.jar".

Why am I not able to get a connection when I pass the username/password in the URL?

Comments

Processing

Post Details

Added on Jan 16 2019
10 comments
29,023 views