Interview Question in SQL Server Configurations


 

Interview Question :: Example applications using DBCP and JNDI


Are there any straight-forward examples containing the correctly configured context.xml and web.xml files for a Tomcat 6 web app....enabling the following code to be used from inside of a servlet?

--------------------------------------...
....
Context initialContext = new InitialContext();
Context env = (Context) initialContext.lookup("java:comp/env");
DataSource dataSource = (DataSource) env.lookup("jdbc/"+databaseName);
connection = dataSource.getConnection();
.....
--------------------------------------...

I would like to implement connection pooling for a few different sql server 2005 data-sources, but my configuration seems to be incorrect.
Answers to "Example applications using DBCP and JNDI"
RE: Example applications using DBCP and JNDI?

You code looks correct. I use a similar code to connect to SQL Server. I have put below a link from the Tomcat website showing an example of how to configure the connection..



Hope that helps.
 
Vote for this answer ::  
Update Alert Setting