This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi Thank you for reading my post. Imagine that i have a jndi datasource like : java:comp/env/jdbc/be now i want to creat a connection from this datasource , how i can do that ? can you please give me the steps ? I want to do it in a servlet.
Raminaa, 1) Create an initial context. Likely this is as simple as: InitialContext ctx = new InitialContext(), but it depends on your app server. 2) Get the datasource from the initial context. - lookup by JNDI name 3) Get a connection from the datasource. - getConnection() method.