Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: MySql Connector

Pid

2007-07-23

Replies:

Mohammed Zabin wrote:
> Thank you, what about testing the connection, i am afraid that the test
> code
> is the reason:

Looks fine. Your log error messages?

> Context initContext = new InitialContext();
> Context envContext = (Context)initContext.lookup("java:/comp/env");
> DataSource ds = (DataSource)envContext.lookup("jdbc/TestMySql");
> Connection conn = ds.getConnection();
>
> out.println("Connection Established");
>
> what is "java:/comp/env"??

(Please just reply to the list, not me as well)

An explanation for the policy behind naming JNDI environment variables
is here:

http://java.sun.com/products/jndi/tutorial/beyond/misc/policy.html




p


> On 7/22/07, Pid <p@(protected):
>>
>> You can define either:
>>
>> a) Resource inside a Context - either in META-INF/context.xml or
>> host/<appname>.xml
>>
>> b) ResourceLink inside a Context (as above) referring to a global
>> Resource defined in server.xml.
>>
>> You're doing both at the moment, so one of them isn't being used,
>> depending on where you placed the Resource in server.xml.
>>
>> Just defining a Resource inside your META-INF/context.xml and the
>> corresponding WEB-INF/web.xml reference should be sufficient.
>>
>>
>>
>> p
>>
>>
>>
>>
>> Mohammed Zabin wrote:
>> > Would you please be more specific? which file you mean? I have created
>> > Oracel connection Pool as the stated way above, and it's worked fine,
>> shall
>> > i put resource defeninitoin in context.xml only?
>> >
>> > On 7/22/07, Pid <p@(protected):
>> >>
>> >> You only need one resource definition.
>> >> You only need a resource link definition if your resource is a global
>> >> one.
>> >>
>> >> Simplify your configuration and then post the error message from the
>> >> logs so we can see Tomcat says is wrong.
>> >>
>> >> p
>> >>
>> >>
>> >> Mohammed Zabin wrote:
>> >> > Hi All
>> >> >
>> >> > I have confiured oracle connection pool on my tomacat 6, and it
>> worked
>> >> > fine.
>> >> > When i came to configure MySql, I repeated the same steps for Oracle
>> >> > databse, with considering the specfication of MySql database. But
>> it's
>> >> > didn't work. Any Help please about configuring MySql,
>> >> > I downloaded MySql connector from mysql website and place it in
>> >> > CATALINA_HOME/lib directory, and i put the following:
>> >> >
>> >> > 1. in server.xml file:
>> >> > <Resource name="jdbc/TestMySql" auth="Container"
>> >> > type="javax.sql.DataSource"
>> >> >             maxActive="100" maxIdle="30" maxWait="10000"
>> >> >             username="*" password="*" driverClassName="
>> >> > com.mysql.jdbc.Driver"
>> >> >
>> >> > url="jdbc:mysql://localhost:3306/exam?autoReconnect=true"/>
>> >> >
>> >> > 2. in web.xml file
>> >> > <resource-ref>
>> >> >    <description>Oracle Datasource example</description>
>> >> >    <res-ref-name>jdbc/TestMySql</res-ref-name>
>> >> >    <res-type>javax.sql.DataSource</res-type>
>> >> >    <res-auth>Container</res-auth>
>> >> > </resource-ref>
>> >> >
>> >> > 3. in context.xml file (on server's context.xml file):
>> >> > <Resource name="jdbc/TestMySql" auth="Container"
>> >> > type="javax.sql.DataSource"
>> >> >             maxActive="100" maxIdle="30" maxWait="10000"
>> >> >             username="*" password="*" driverClassName="
>> >> > com.mysql.jdbc.Driver"
>> >> >             url="jdbc:mysql://localhost:3306/exam"/>
>> >> >
>> >> > 4. in cotext.xml file ( In my web application's context.xml file):
>> >> > <ResourceLink global="jdbc/TestMySql" name="jdbc/TestMySql" type="
>> >> > javax.sql.DataSource"/>
>> >> >
>> >> > Any Help please?
>> >> >
>> >>
>> >>
>> >>
>> >
>>
>>
>>
>


Attachment: smime.p7s
©2008 junlu.com - Jax Systems, LLC, U.S.A.