I've had that same problem a few days ago.


Besides the code you already typed (which seems to be ok) you will need to have:

1) The library (.jar) under your JSP container's specific sub directory
(e.g. d:\tomcat\common\lib). Not on your application (so it works from any other application you want to create on the future)


2) A .xml file (named exactly the same as your context with the specification of your connection.

<Resource name="jdbc/DailyUsers" auth="Container" type="javax.sql.DataSource" />
<ResourceParams name="jdbc/DailyUsers">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.postgresql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:postgresql://localhost:5432/users</value>
</parameter>
<parameter>
<name>username</name>
<value>abcdef</value>
</parameter>
<parameter>
<name>password</name>
<value>123456789</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>



This examples uses a postgres jdbc, you might change drivers & stuff for your own jdbc.


Good look!!!

Reply via email to