Darbininkai Broliai
Darbininkai Broliai

Reputation: 159

Tomcat jdbc pool doesn't work

I am having a slight problem with using JDBC tomcat pool. I have properly defined the resource in context.xml, as well as referring to it in web.xml. Now in my Database access method, I would like to somehow get a data source for when a user get something from the database. However, when I type this in:

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/testDB");

I get the error message "InitialContext cannot be resolved to a type". What is the problem here?

Upvotes: 1

Views: 115

Answers (1)

einnocent
einnocent

Reputation: 4009

Be sure to import InitialContext, it sounds like it is missing to the compiler.

Upvotes: 2

Related Questions