Skip to Main Content

New to Java

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!

JNDI user name and password

scottjhnApr 28 2010 — edited Apr 29 2010
Case 1, for a NON-JNDI based database connection:

Connection conn = DriverManager.getConnection(url, "username", "password");


Case 2, for a JNDI based database connection:

Context context = new InitialContext();
DataSource dataSource = (DataSource) context.lookup("java:comp/env/jdbc/test");
Connection conn = dataSource.getConnection();

Notice that for NON-JNDI based database connection, the username and password are specified. But for the
JNDI based database connection, there is no username and password specified. How come? If I want to specify the username and password for JNDI based connection, how can I do it?


Thanks

Scott
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 27 2010
Added on Apr 28 2010
5 comments
2,695 views