- This topic has 2 replies, 2 voices, and was last updated 21 years, 6 months ago by
Scott Anderson.
-
AuthorPosts
-
waybckMemberHi.
I’ve been working on a web-project in eclipse, and I really missed the jsp code completion functionality I’ve been used from other tools. Luckily I found MyEclipse, which seems to do a perfect job with jsps.
My problem is that I use connection pooling for MySql in my project. It is set up this way :
Using the “Sysdeo Eclipse Tomcat Launcher Plugin” I created a new “Tomcat project”. This creates a context in the Tomcat server.xml file which links to the web files. Then I can define a new global tomcat jndi resource in the server.xml :
<ResourceParams name=”jdbc/CMS”>
<parameter>
<name>factory</name>
<value>com.java_internals.resourcefactory.MyResourceFactory</value>
</parameter><parameter>
<name>databaseName</name>
<value>cms</value>
</parameter><!– Maximum number of dB connections in pool. –>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter><parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
</ResourceParams>This resource is possible to link to my web context, as the context is defined in the server.xml file :
<Context path=”/CMS” >
<ResourceLink name=”jdbc/CMS” global=”jdbc/CMS” type=”com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource” />
</Context>When I do a jndi lookup in my servlets now, I can get a connection from the connection pool.
What I want to know is how to acheive this using the MyEclipse Web Module, as this web project is not deployed in the tomcat server.xml file, but in its own folder structure.
Any help would be appreciated !
Best Regards
Eirik Kjølsrud, Norway
waybckMemberHi.
After a lot of trouble, I managed to solve it. Please tell me if my fix is not a good one…
What I did was to add a <Context> element to the tomcat server.xml file representing the web module,
<Context path=”/testweb” docBase=”testweb” debug=”0″ reloadable=”true”>
Then I added a datasource resurce to it. Voilla, it worked from my old code…
<ResourceParams name=”jdbc/test”>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>password</name>
<value>masterkey</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/cms</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>username</name>
<value>root</value>
</parameter>
</ResourceParams>
</Context>
Scott AndersonParticipantEirik,
Please tell me if my fix is not a good one…
First, all solutions are good ones. 🙂
Unforunately, I’m certainly no Tomcat configuration expert but I can tell you how such things are solved in other servers and maybe you can determine if there is a Tomcat analogy. In most application servers, database connection pools are a shared resource available to any application running in the server; they are not specific to a context. So, they are typically installed using the console at a global level and are then referenced with entries in server-specific deployment descriptors. I don’t know if Tomcat allows this kind of thing or not. If not, then what you did may be the only solution. Does anyone else know for sure?
–Scott
MyEclipse Support -
AuthorPosts