S
Simon Harvey
Hi there,
I have copied the following code which seems to work in my webapp:
Context init = new InitialContext();
Context ctx = (Context) init.lookup("java:comp/env");
DataSource dataSource = (DataSource) ctx.lookup("jdbc/datasource");
The reason why I have done this is because I want to use connection pooling
and I have made the necessary changes to tomcat to support this. But my
question is simply, assuming that I have done everything correctly, with the
code above, am I know ready to start getting pooled connections when i ask
the datasource?
The reason why I ask is because I have seen code that makes specific
reference to ConnectionPools and so on, but as you can see, the code above
says nothing about pools at all. I did copy the code from an article on CP
so I'm sure it is, but I just need to confirm and ask why some examples are
dong in a different way?
Doing it this way, does a datasource automatically provide connection
pooling? Do they all do that? If some don't, what happens - does the code
need changed?
Thanks everyone
Take care
Simon
I have copied the following code which seems to work in my webapp:
Context init = new InitialContext();
Context ctx = (Context) init.lookup("java:comp/env");
DataSource dataSource = (DataSource) ctx.lookup("jdbc/datasource");
The reason why I have done this is because I want to use connection pooling
and I have made the necessary changes to tomcat to support this. But my
question is simply, assuming that I have done everything correctly, with the
code above, am I know ready to start getting pooled connections when i ask
the datasource?
The reason why I ask is because I have seen code that makes specific
reference to ConnectionPools and so on, but as you can see, the code above
says nothing about pools at all. I did copy the code from an article on CP
so I'm sure it is, but I just need to confirm and ask why some examples are
dong in a different way?
Doing it this way, does a datasource automatically provide connection
pooling? Do they all do that? If some don't, what happens - does the code
need changed?
Thanks everyone
Take care
Simon