JNDI user name and password
scottjhnApr 28 2010 — edited Apr 29 2010Case 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