> Despite my posting - and I really hope someone chips in concerning the
> question I raised about the <resource-ref> being redundant in the deployment
> descriptor (!) - the first thing to say is, have faith!
>
> Connection pooling works, and it is actually quite simple, so do not give up
> on it.
Cheers for the advice Harry... here's where I'm at....
I have no choice on the giving up side of things, need to implement it
for some client code I'm working on
;-)
I've been doing a lot of googling to try and get answers so I may have
got crossed wires, I had a version working (or thinking it was working)
with the info in $JAKARTA_HOME/conf/server.xml but I wasn't happy with
this solution (preferring to have the connection defined in
$JAKARTA_HOME/conf/Catalina/localhost/<app_name>.xml for good reasons...
so I'm basically restarting and I now have the following config
$JAKARTA_HOME/conf/Catalina/localhost/<app_name>.xml
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="dev-sstl" path="/dev-sstl" reloadable="true"
useNaming="false">
<Resource
name="jdbc/mysql"
type="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"
auth="Container"/>
<ResourceParams name="jdbc/mysql">
<parameter>
<name>factory</name>
<value>com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory</value>
</parameter>
<parameter>
<name>port</name>
<value>3306</value>
</parameter>
<parameter>
<name>user</name>
<value>USERNAME</value>
</parameter>
<parameter>
<name>password</name>
<value>PASSWORD</value>
</parameter>
<parameter>
<name>serverName</name>
<value>localhost</value>
</parameter>
<parameter>
<name>databaseName</name>
<value>DATABASE</value>
</parameter>
<parameter>
<name>explicitUrl</name>
<value>true</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/DATABASE?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&max-connections=50&min-connections=2&inactivity-timeout=30&wait-timeout=30</value>
</parameter>
</ResourceParams>
</Context>
The info for the above i gleaned from
http://www.russellbeattie.com/notebook/1006529.html
Then in <web_app>/WEB-INF/web.xml I have
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<resource-ref>
<description>DB connection</description>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
Then in my test JSP I have
try {
Context ctx = new InitialContext();
DataSource ds = ( DataSource ) ctx.lookup("java:comp/env/jdbc/MyDS" );
Connection conn = ds.getConnection();
...
And the error I get is
javax.servlet.ServletException: Name java:comp is not bound in this
Context
Which is an error I've managed to hit several times, I know the whole
connection pooling is the right way to go about this, just surprised at
how long it is taking me to get going (I dread to think what it will be
like installing this live with the client, but I'll save that happy
thought for later)
As ever any help much appreciated... (and if the person who helps me to
get this working is ever in London I'll stand them a beer or 3)
;-)
TIA
Dave
--
David Smith <[EMAIL PROTECTED]>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]