You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mohammed Zabin <jo...@gmail.com> on 2007/07/22 10:36:34 UTC

MySql Connector

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="root" password="exam" 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="root" password="exam" 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?

Re: MySql Connector

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mohammed,

Mohammed Zabin wrote:
> I did this, but i think that there is an option to enable logging, do u
> know it?

Logs should go to catalina.out, or to the console if you're using
windows and startup.bat instead of a service.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFGp2oo9CaO5/Lv0PARAjg+AJjbycd41PSmCMnHIGJp1/jpN/L+AJ9IJNG5
tPRRLlrf/eySyIoS7vBw0A==
=B4XC
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by David Smith <dn...@cornell.edu>.
Not sure ... you could take a look at 
http://tomcat.apache.org/tomcat-5.5-doc/logging.html.  Tomcat's always 
provided a complete stack and cited the code in error for me without any 
changes in logging config.

You could also post the complete jsp you are using for a test.  See if 
the error stands out to one of us on the list.

--David

Mohammed Zabin wrote:

> I did this, but i think that there is an option to enable logging, do 
> u know
> it?
>
> On 7/25/07, David Smith <dn...@cornell.edu> wrote:
>
>>
>> I'm starting to think there's something really funny (ie broken) with
>> your tomcat install.  Could you clean install another instance of tomcat
>> (preferably downloaded from the tomcat website) and check the code 
>> there?
>>
>> --David
>>
>> Mohammed Zabin wrote:
>> > This is all the exception message, I looked inside logs folder, i
>> > found an
>> > empty file, it continas nothing :~
>> >
>> > On 7/25/07, David Smith <dn...@cornell.edu> wrote:
>> >>
>> >> Your stack trace appears to be incomplete.  Could you post more?  It
>> >> appears to be a compile error and should cite the code in question.
>> >>
>> >> --David
>> >>
>> >> Mohammed Zabin wrote:
>> >> > For test purposes, i have wrote the following code as a java 
>> program
>> >> > and it
>> >> > worked fine, but when I tried it in a jsp page i got the following
>> >> error:
>> >> >
>> >> > Class.forName("com.mysql.jdbc.Driver");
>> >> > String url = "jdbc:mysql://localhost:3306/exam";
>> >> > Connection con = DriverManager.getConnection(url,"root", "exam");
>> >> > Statement stmt = con.createStatement();
>> >> > ResultSet rs = stmt.executeQuery("Select type from questions");
>> >> >
>> >> > while( rs.next() ) {
>> >> >     System.out.println( rs.getString("type") );
>> >> > }
>> >> >
>> >> >
>> >> > org.apache.jasper.JasperException: Unable to compile class for JSP:
>> >> >
>> >> >
>> >> >
>> >> > Stacktrace:
>> >> >     org.apache.jasper.compiler.DefaultErrorHandler.javacError(
>> >> DefaultErrorHandler.java:85)
>> >> >
>> >> >     org.apache.jasper.compiler.ErrorDispatcher.javacError(
>> >> ErrorDispatcher.java:330)
>> >> >
>> >> >     org.apache.jasper.compiler.JDTCompiler.generateClass(
>> >> JDTCompiler.java:415)
>> >> >
>> >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
>> >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
>> >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
>> >> >     org.apache.jasper.JspCompilationContext.compile(
>> >> JspCompilationContext.java:566)
>> >> >
>> >> >     org.apache.jasper.servlet.JspServletWrapper.service(
>> >> JspServletWrapper.java:308)
>> >> >
>> >> >
>> >> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
>> >> :320)
>> >> >
>> >> >     
>> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>> >> >     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>> >> >
>> >> >
>> >> >
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by Mohammed Zabin <jo...@gmail.com>.
I did this, but i think that there is an option to enable logging, do u know
it?

On 7/25/07, David Smith <dn...@cornell.edu> wrote:
>
> I'm starting to think there's something really funny (ie broken) with
> your tomcat install.  Could you clean install another instance of tomcat
> (preferably downloaded from the tomcat website) and check the code there?
>
> --David
>
> Mohammed Zabin wrote:
> > This is all the exception message, I looked inside logs folder, i
> > found an
> > empty file, it continas nothing :~
> >
> > On 7/25/07, David Smith <dn...@cornell.edu> wrote:
> >>
> >> Your stack trace appears to be incomplete.  Could you post more?  It
> >> appears to be a compile error and should cite the code in question.
> >>
> >> --David
> >>
> >> Mohammed Zabin wrote:
> >> > For test purposes, i have wrote the following code as a java program
> >> > and it
> >> > worked fine, but when I tried it in a jsp page i got the following
> >> error:
> >> >
> >> > Class.forName("com.mysql.jdbc.Driver");
> >> > String url = "jdbc:mysql://localhost:3306/exam";
> >> > Connection con = DriverManager.getConnection(url,"root", "exam");
> >> > Statement stmt = con.createStatement();
> >> > ResultSet rs = stmt.executeQuery("Select type from questions");
> >> >
> >> > while( rs.next() ) {
> >> >     System.out.println( rs.getString("type") );
> >> > }
> >> >
> >> >
> >> > org.apache.jasper.JasperException: Unable to compile class for JSP:
> >> >
> >> >
> >> >
> >> > Stacktrace:
> >> >     org.apache.jasper.compiler.DefaultErrorHandler.javacError(
> >> DefaultErrorHandler.java:85)
> >> >
> >> >     org.apache.jasper.compiler.ErrorDispatcher.javacError(
> >> ErrorDispatcher.java:330)
> >> >
> >> >     org.apache.jasper.compiler.JDTCompiler.generateClass(
> >> JDTCompiler.java:415)
> >> >
> >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
> >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
> >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
> >> >     org.apache.jasper.JspCompilationContext.compile(
> >> JspCompilationContext.java:566)
> >> >
> >> >     org.apache.jasper.servlet.JspServletWrapper.service(
> >> JspServletWrapper.java:308)
> >> >
> >> >
> >> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
> >> :320)
> >> >
> >> >     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> >> >     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >> >
> >> >
> >> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: MySql Connector

Posted by David Smith <dn...@cornell.edu>.
I'm starting to think there's something really funny (ie broken) with 
your tomcat install.  Could you clean install another instance of tomcat 
(preferably downloaded from the tomcat website) and check the code there?

--David

Mohammed Zabin wrote:
> This is all the exception message, I looked inside logs folder, i 
> found an
> empty file, it continas nothing :~
>
> On 7/25/07, David Smith <dn...@cornell.edu> wrote:
>>
>> Your stack trace appears to be incomplete.  Could you post more?  It
>> appears to be a compile error and should cite the code in question.
>>
>> --David
>>
>> Mohammed Zabin wrote:
>> > For test purposes, i have wrote the following code as a java program
>> > and it
>> > worked fine, but when I tried it in a jsp page i got the following
>> error:
>> >
>> > Class.forName("com.mysql.jdbc.Driver");
>> > String url = "jdbc:mysql://localhost:3306/exam";
>> > Connection con = DriverManager.getConnection(url,"root", "exam");
>> > Statement stmt = con.createStatement();
>> > ResultSet rs = stmt.executeQuery("Select type from questions");
>> >
>> > while( rs.next() ) {
>> >     System.out.println( rs.getString("type") );
>> > }
>> >
>> >
>> > org.apache.jasper.JasperException: Unable to compile class for JSP:
>> >
>> >
>> >
>> > Stacktrace:
>> >     org.apache.jasper.compiler.DefaultErrorHandler.javacError(
>> DefaultErrorHandler.java:85)
>> >
>> >     org.apache.jasper.compiler.ErrorDispatcher.javacError(
>> ErrorDispatcher.java:330)
>> >
>> >     org.apache.jasper.compiler.JDTCompiler.generateClass(
>> JDTCompiler.java:415)
>> >
>> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
>> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
>> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
>> >     org.apache.jasper.JspCompilationContext.compile(
>> JspCompilationContext.java:566)
>> >
>> >     org.apache.jasper.servlet.JspServletWrapper.service(
>> JspServletWrapper.java:308)
>> >
>> >     
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
>> :320)
>> >
>> >     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>> >     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>> >
>> >
>> > 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by Mohammed Zabin <jo...@gmail.com>.
This is all the exception message, I looked inside logs folder, i found an
empty file, it continas nothing :~

On 7/25/07, David Smith <dn...@cornell.edu> wrote:
>
> Your stack trace appears to be incomplete.  Could you post more?  It
> appears to be a compile error and should cite the code in question.
>
> --David
>
> Mohammed Zabin wrote:
> > For test purposes, i have wrote the following code as a java program
> > and it
> > worked fine, but when I tried it in a jsp page i got the following
> error:
> >
> > Class.forName("com.mysql.jdbc.Driver");
> > String url = "jdbc:mysql://localhost:3306/exam";
> > Connection con = DriverManager.getConnection(url,"root", "exam");
> > Statement stmt = con.createStatement();
> > ResultSet rs = stmt.executeQuery("Select type from questions");
> >
> > while( rs.next() ) {
> >     System.out.println( rs.getString("type") );
> > }
> >
> >
> > org.apache.jasper.JasperException: Unable to compile class for JSP:
> >
> >
> >
> > Stacktrace:
> >     org.apache.jasper.compiler.DefaultErrorHandler.javacError(
> DefaultErrorHandler.java:85)
> >
> >     org.apache.jasper.compiler.ErrorDispatcher.javacError(
> ErrorDispatcher.java:330)
> >
> >     org.apache.jasper.compiler.JDTCompiler.generateClass(
> JDTCompiler.java:415)
> >
> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
> >     org.apache.jasper.JspCompilationContext.compile(
> JspCompilationContext.java:566)
> >
> >     org.apache.jasper.servlet.JspServletWrapper.service(
> JspServletWrapper.java:308)
> >
> >     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
> :320)
> >
> >     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> >     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >
> >
> >
> > On 7/25/07, Mohammed Zabin <jo...@gmail.com> wrote:
> >>
> >> In cotrast, i have installed Oracle and worked very well, but MySql
> >> didn't
> >> work with me. I am using Connecter/J from MySql website, the beta
> >> version, I
> >> put the jar file in the CATALINA_HOME/lib, and i add it to the
> >> CLASSPATH.
> >> and I followed the instructions provided in Tomcat documentation,
> >> exactly,
> >> Didn't work :(
> >>
> >> On 7/24/07, David Smith <dn...@cornell.edu> wrote:
> >> >
> >> > I've never dealt with Oracle but have done a lot of MySQL installs
> >> > without a single failure.  Your config outside of the web.xml doesn't
> >> > look wrong in any way.
> >> >
> >> > You might want to put the <resource-ref> block in your web.xml as
> >> > described in the how-to's.  It doesn't hurt and is part of the
> servlet
> >> > spec.
> >> >
> >> > --David
> >> >
> >> >
> >> > Mohammed Zabin wrote:
> >> >
> >> > > No, the same error, You know what David?? I put nothing in
> >> web.xml, I
> >> > am
> >> > > confused about this issue, when to use web.xml, and it might be the
> >> > > reason
> >> > > behind the unsuccessfull MySql Connection, I follow the same
> >> procedure
> >> > I
> >> > > followed to configure Oracle DBCP, I think it must work for MySql,
> >> > right?
> >> > >
> >> > > On 7/24/07, David Smith <dn...@cornell.edu> wrote:
> >> > >
> >> > >>
> >> > >> Try this variant of your code:
> >> > >>
> >> > >> Context initContext = new InitialContext();
> >> > >> DataSource ds  =
> >> > >> (DataSource)initContext.lookup("java:comp/env/jdbc/TestMySql");
> >> > >> Connection conn = ds.getConnection ();
> >> > >>
> >> > >> out.println("Connection Established");
> >> > >>
> >> > >> Essentially when you lookup java:comp/env/jdbc/TestMySql, that's
> >> the
> >> > >> full JNDI path to the DataSource and returns a DataSource type
> >> > object,
> >> > >> not a Context type object.
> >> > >>
> >> > >> --David
> >> > >>
> >> > >> Mohammed Zabin wrote:
> >> > >>
> >> > >> > Ok thank you, I did the following as you have stated:
> >> > >> >
> >> > >> > 1. in server.xml:
> >> > >> > <Resource name="jdbc/TestMySql" auth="Container"
> >> > >> > type="javax.sql.DataSource"
> >> > >> >                   maxActive="100" maxIdle="30" maxWait="10000"
> >> > >> >                   username="root" password="exam"
> >> driverClassName="
> >> > >> > com.mysql.jdbc.Driver"
> >> > >> >                   url="jdbc:mysql://localhost:3306/exam"/>
> >> > >> > 2. in context.xml
> >> > >> > <ResourceLink global="jdbc/TestMySql" name="jdbc/TestMySql"
> >> type="
> >> > >> > javax.sql.DataSource"/>
> >> > >> >
> >> > >> > 3. in my test page:
> >> > >> >  Context initContext = new InitialContext();
> >> > >> >  Context envContext  =
> >> > >> > (Context)initContext.lookup("java:comp/env/jdbc/TestMySql");
> >> > >> >  DataSource ds =
> (DataSource)envContext.lookup("jdbc/TestMySql");
> >> > >> >  Connection conn = ds.getConnection();
> >> > >> >
> >> > >> >  out.println("Connection Established");
> >> > >> > And i put nothing in web.xml, I have the following error:
> >> > >> >
> >> > >> > org.apache.jasper.JasperException: Unable to compile class for
> >> JSP:
> >> > >> >
> >> > >> >
> >> > >> >
> >> > >> > Stacktrace:
> >> > >> >     org.apache.jasper.compiler.DefaultErrorHandler.javacError (
> >> > >> DefaultErrorHandler.java:85)
> >> > >> >
> >> > >> >     org.apache.jasper.compiler.ErrorDispatcher.javacError(
> >> > >> ErrorDispatcher.java:330)
> >> > >> >
> >> > >> >     org.apache.jasper.compiler.JDTCompiler.generateClass (
> >> > >> JDTCompiler.java:415)
> >> > >> >
> >> > >> >
> >> org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
> >> > >> >
> >> org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
> >> > >> >
> >> org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
> >> > >> >     org.apache.jasper.JspCompilationContext.compile(
> >> > >> JspCompilationContext.java:566)
> >> > >> >
> >> > >> >     org.apache.jasper.servlet.JspServletWrapper.service(
> >> > >> JspServletWrapper.java:308)
> >> > >> >
> >> > >> >
> >> > >> org.apache.jasper.servlet.JspServlet.serviceJspFile(
> JspServlet.java
> >> > >> :320)
> >> > >> >
> >> > >> >     org.apache.jasper.servlet.JspServlet.service(JspServlet.java
> >> > :266)
> >> > >> >     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >> > >> >
> >> > >> >
> >> > >> >
> >> > >> > On 7/23/07, David Smith <dn...@cornell.edu> wrote:
> >> > >> >
> >> > >> >>
> >> > >> >> A few things to consider:
> >> > >> >>
> >> > >> >> 1. Either place your Resource definition in server.xml as a
> >> > >> >> GlobalResource *OR* in your webapp's context.xml file.
> >> > >> >>
> >> > >> >> 2. If you have the Resource defined in the GlobalResources,
> >> that's
> >> >
> >> > >> the
> >> > >> >> only time you need to use a ResourceLink element in context.xml
> .
> >> > >> >>
> >> > >> >> 3. Drop the autoReconnect parameter in your mysql URL.  It has
> >> > it's
> >> > >> >> uses, but not in a pooled environment.
> >> > >> >>
> >> > >> >> 4. You should probably be attempting to use the path
> >> > >> >> java:comp/env/jdbc/TestMySQL (note the lack of a '/' before
> >> comp)
> >> > as
> >> > >> >> described in the JNDI howto on tomcat's website.  I think I saw
> >> > you
> >> > >> >> using java:/comp/env/jdbc/TestMySQL in one of your posts.
> >> > >> >>
> >> > >> >> 5. Please post relevant messages from your logs if this isn't
> >> > >> working.
> >> > >> >>
> >> > >> >> --David
> >> > >> >>
> >> > >> >> 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...@pidster.com> wrote:
> >> > >> >> >
> >> > >> >> >>
> >> > >> >> >> 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?
> >> > >> >> >> >
> >> > >> >> >>
> >> > >> >> >>
> >> > >> >> >>
> >> > >> >> >
> >> > >> >>
> >> > >> >>
> >> > >> >>
> >> > ---------------------------------------------------------------------
> >> > >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> > >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> > >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> > >> >>
> >> > >> >>
> >> > >> >
> >> > >>
> >> > >>
> >> > >>
> >> ---------------------------------------------------------------------
> >> >
> >> > >> To start a new topic, e-mail: users@tomcat.apache.org
> >> > >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> > >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> > >>
> >> > >>
> >> > >
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To start a new topic, e-mail: users@tomcat.apache.org
> >> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> > For additional commands, e-mail: users-help@tomcat.apache.org
> >> >
> >> >
> >>
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: MySql Connector

Posted by David Smith <dn...@cornell.edu>.
Your stack trace appears to be incomplete.  Could you post more?  It 
appears to be a compile error and should cite the code in question.

--David

Mohammed Zabin wrote:
> For test purposes, i have wrote the following code as a java program 
> and it
> worked fine, but when I tried it in a jsp page i got the following error:
>
> Class.forName("com.mysql.jdbc.Driver");
> String url = "jdbc:mysql://localhost:3306/exam";
> Connection con = DriverManager.getConnection(url,"root", "exam");
> Statement stmt = con.createStatement();
> ResultSet rs = stmt.executeQuery("Select type from questions");
>
> while( rs.next() ) {
>     System.out.println( rs.getString("type") );
> }
>
>
> org.apache.jasper.JasperException: Unable to compile class for JSP:
>
>
>
> Stacktrace:
>     org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85) 
>
>     org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) 
>
>     org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415) 
>
>     org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
>     org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
>     org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
>     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566) 
>
>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308) 
>
>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) 
>
>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>
>
> On 7/25/07, Mohammed Zabin <jo...@gmail.com> wrote:
>>
>> In cotrast, i have installed Oracle and worked very well, but MySql 
>> didn't
>> work with me. I am using Connecter/J from MySql website, the beta 
>> version, I
>> put the jar file in the CATALINA_HOME/lib, and i add it to the 
>> CLASSPATH.
>> and I followed the instructions provided in Tomcat documentation, 
>> exactly,
>> Didn't work :(
>>
>> On 7/24/07, David Smith <dn...@cornell.edu> wrote:
>> >
>> > I've never dealt with Oracle but have done a lot of MySQL installs
>> > without a single failure.  Your config outside of the web.xml doesn't
>> > look wrong in any way.
>> >
>> > You might want to put the <resource-ref> block in your web.xml as
>> > described in the how-to's.  It doesn't hurt and is part of the servlet
>> > spec.
>> >
>> > --David
>> >
>> >
>> > Mohammed Zabin wrote:
>> >
>> > > No, the same error, You know what David?? I put nothing in 
>> web.xml, I
>> > am
>> > > confused about this issue, when to use web.xml, and it might be the
>> > > reason
>> > > behind the unsuccessfull MySql Connection, I follow the same 
>> procedure
>> > I
>> > > followed to configure Oracle DBCP, I think it must work for MySql,
>> > right?
>> > >
>> > > On 7/24/07, David Smith <dn...@cornell.edu> wrote:
>> > >
>> > >>
>> > >> Try this variant of your code:
>> > >>
>> > >> Context initContext = new InitialContext();
>> > >> DataSource ds  =
>> > >> (DataSource)initContext.lookup("java:comp/env/jdbc/TestMySql");
>> > >> Connection conn = ds.getConnection ();
>> > >>
>> > >> out.println("Connection Established");
>> > >>
>> > >> Essentially when you lookup java:comp/env/jdbc/TestMySql, that's 
>> the
>> > >> full JNDI path to the DataSource and returns a DataSource type
>> > object,
>> > >> not a Context type object.
>> > >>
>> > >> --David
>> > >>
>> > >> Mohammed Zabin wrote:
>> > >>
>> > >> > Ok thank you, I did the following as you have stated:
>> > >> >
>> > >> > 1. in server.xml:
>> > >> > <Resource name="jdbc/TestMySql" auth="Container"
>> > >> > type="javax.sql.DataSource"
>> > >> >                   maxActive="100" maxIdle="30" maxWait="10000"
>> > >> >                   username="root" password="exam" 
>> driverClassName="
>> > >> > com.mysql.jdbc.Driver"
>> > >> >                   url="jdbc:mysql://localhost:3306/exam"/>
>> > >> > 2. in context.xml
>> > >> > <ResourceLink global="jdbc/TestMySql" name="jdbc/TestMySql" 
>> type="
>> > >> > javax.sql.DataSource"/>
>> > >> >
>> > >> > 3. in my test page:
>> > >> >  Context initContext = new InitialContext();
>> > >> >  Context envContext  =
>> > >> > (Context)initContext.lookup("java:comp/env/jdbc/TestMySql");
>> > >> >  DataSource ds = (DataSource)envContext.lookup("jdbc/TestMySql");
>> > >> >  Connection conn = ds.getConnection();
>> > >> >
>> > >> >  out.println("Connection Established");
>> > >> > And i put nothing in web.xml, I have the following error:
>> > >> >
>> > >> > org.apache.jasper.JasperException: Unable to compile class for 
>> JSP:
>> > >> >
>> > >> >
>> > >> >
>> > >> > Stacktrace:
>> > >> >     org.apache.jasper.compiler.DefaultErrorHandler.javacError (
>> > >> DefaultErrorHandler.java:85)
>> > >> >
>> > >> >     org.apache.jasper.compiler.ErrorDispatcher.javacError(
>> > >> ErrorDispatcher.java:330)
>> > >> >
>> > >> >     org.apache.jasper.compiler.JDTCompiler.generateClass (
>> > >> JDTCompiler.java:415)
>> > >> >
>> > >> >     
>> org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
>> > >> >     
>> org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
>> > >> >     
>> org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
>> > >> >     org.apache.jasper.JspCompilationContext.compile(
>> > >> JspCompilationContext.java:566)
>> > >> >
>> > >> >     org.apache.jasper.servlet.JspServletWrapper.service(
>> > >> JspServletWrapper.java:308)
>> > >> >
>> > >> >
>> > >> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
>> > >> :320)
>> > >> >
>> > >> >     org.apache.jasper.servlet.JspServlet.service(JspServlet.java
>> > :266)
>> > >> >     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>> > >> >
>> > >> >
>> > >> >
>> > >> > On 7/23/07, David Smith <dn...@cornell.edu> wrote:
>> > >> >
>> > >> >>
>> > >> >> A few things to consider:
>> > >> >>
>> > >> >> 1. Either place your Resource definition in server.xml as a
>> > >> >> GlobalResource *OR* in your webapp's context.xml file.
>> > >> >>
>> > >> >> 2. If you have the Resource defined in the GlobalResources, 
>> that's
>> >
>> > >> the
>> > >> >> only time you need to use a ResourceLink element in context.xml.
>> > >> >>
>> > >> >> 3. Drop the autoReconnect parameter in your mysql URL.  It has
>> > it's
>> > >> >> uses, but not in a pooled environment.
>> > >> >>
>> > >> >> 4. You should probably be attempting to use the path
>> > >> >> java:comp/env/jdbc/TestMySQL (note the lack of a '/' before 
>> comp)
>> > as
>> > >> >> described in the JNDI howto on tomcat's website.  I think I saw
>> > you
>> > >> >> using java:/comp/env/jdbc/TestMySQL in one of your posts.
>> > >> >>
>> > >> >> 5. Please post relevant messages from your logs if this isn't
>> > >> working.
>> > >> >>
>> > >> >> --David
>> > >> >>
>> > >> >> 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...@pidster.com> wrote:
>> > >> >> >
>> > >> >> >>
>> > >> >> >> 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?
>> > >> >> >> >
>> > >> >> >>
>> > >> >> >>
>> > >> >> >>
>> > >> >> >
>> > >> >>
>> > >> >>
>> > >> >>
>> > ---------------------------------------------------------------------
>> > >> >> To start a new topic, e-mail: users@tomcat.apache.org
>> > >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> > >> >> For additional commands, e-mail: users-help@tomcat.apache.org
>> > >> >>
>> > >> >>
>> > >> >
>> > >>
>> > >>
>> > >> 
>> ---------------------------------------------------------------------
>> >
>> > >> To start a new topic, e-mail: users@tomcat.apache.org
>> > >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> > >> For additional commands, e-mail: users-help@tomcat.apache.org
>> > >>
>> > >>
>> > >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To start a new topic, e-mail: users@tomcat.apache.org
>> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> > For additional commands, e-mail: users-help@tomcat.apache.org
>> >
>> >
>>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by Mohammed Zabin <jo...@gmail.com>.
For test purposes, i have wrote the following code as a java program and it
worked fine, but when I tried it in a jsp page i got the following error:

Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/exam";
Connection con = DriverManager.getConnection(url,"root", "exam");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select type from questions");

while( rs.next() ) {
     System.out.println( rs.getString("type") );
}


org.apache.jasper.JasperException: Unable to compile class for JSP:



Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



On 7/25/07, Mohammed Zabin <jo...@gmail.com> wrote:
>
> In cotrast, i have installed Oracle and worked very well, but MySql didn't
> work with me. I am using Connecter/J from MySql website, the beta version, I
> put the jar file in the CATALINA_HOME/lib, and i add it to the CLASSPATH.
> and I followed the instructions provided in Tomcat documentation, exactly,
> Didn't work :(
>
> On 7/24/07, David Smith <dn...@cornell.edu> wrote:
> >
> > I've never dealt with Oracle but have done a lot of MySQL installs
> > without a single failure.  Your config outside of the web.xml doesn't
> > look wrong in any way.
> >
> > You might want to put the <resource-ref> block in your web.xml as
> > described in the how-to's.  It doesn't hurt and is part of the servlet
> > spec.
> >
> > --David
> >
> >
> > Mohammed Zabin wrote:
> >
> > > No, the same error, You know what David?? I put nothing in web.xml, I
> > am
> > > confused about this issue, when to use web.xml, and it might be the
> > > reason
> > > behind the unsuccessfull MySql Connection, I follow the same procedure
> > I
> > > followed to configure Oracle DBCP, I think it must work for MySql,
> > right?
> > >
> > > On 7/24/07, David Smith <dn...@cornell.edu> wrote:
> > >
> > >>
> > >> Try this variant of your code:
> > >>
> > >> Context initContext = new InitialContext();
> > >> DataSource ds  =
> > >> (DataSource)initContext.lookup("java:comp/env/jdbc/TestMySql");
> > >> Connection conn = ds.getConnection ();
> > >>
> > >> out.println("Connection Established");
> > >>
> > >> Essentially when you lookup java:comp/env/jdbc/TestMySql, that's the
> > >> full JNDI path to the DataSource and returns a DataSource type
> > object,
> > >> not a Context type object.
> > >>
> > >> --David
> > >>
> > >> Mohammed Zabin wrote:
> > >>
> > >> > Ok thank you, I did the following as you have stated:
> > >> >
> > >> > 1. in server.xml:
> > >> > <Resource name="jdbc/TestMySql" auth="Container"
> > >> > type="javax.sql.DataSource"
> > >> >                   maxActive="100" maxIdle="30" maxWait="10000"
> > >> >                   username="root" password="exam" driverClassName="
> > >> > com.mysql.jdbc.Driver"
> > >> >                   url="jdbc:mysql://localhost:3306/exam"/>
> > >> > 2. in context.xml
> > >> > <ResourceLink global="jdbc/TestMySql" name="jdbc/TestMySql" type="
> > >> > javax.sql.DataSource"/>
> > >> >
> > >> > 3. in my test page:
> > >> >  Context initContext = new InitialContext();
> > >> >  Context envContext  =
> > >> > (Context)initContext.lookup("java:comp/env/jdbc/TestMySql");
> > >> >  DataSource ds = (DataSource)envContext.lookup("jdbc/TestMySql");
> > >> >  Connection conn = ds.getConnection();
> > >> >
> > >> >  out.println("Connection Established");
> > >> > And i put nothing in web.xml, I have the following error:
> > >> >
> > >> > org.apache.jasper.JasperException: Unable to compile class for JSP:
> > >> >
> > >> >
> > >> >
> > >> > Stacktrace:
> > >> >     org.apache.jasper.compiler.DefaultErrorHandler.javacError (
> > >> DefaultErrorHandler.java:85)
> > >> >
> > >> >     org.apache.jasper.compiler.ErrorDispatcher.javacError(
> > >> ErrorDispatcher.java:330)
> > >> >
> > >> >     org.apache.jasper.compiler.JDTCompiler.generateClass (
> > >> JDTCompiler.java:415)
> > >> >
> > >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
> > >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
> > >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
> > >> >     org.apache.jasper.JspCompilationContext.compile(
> > >> JspCompilationContext.java:566)
> > >> >
> > >> >     org.apache.jasper.servlet.JspServletWrapper.service(
> > >> JspServletWrapper.java:308)
> > >> >
> > >> >
> > >> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
> > >> :320)
> > >> >
> > >> >     org.apache.jasper.servlet.JspServlet.service(JspServlet.java
> > :266)
> > >> >     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> > >> >
> > >> >
> > >> >
> > >> > On 7/23/07, David Smith <dn...@cornell.edu> wrote:
> > >> >
> > >> >>
> > >> >> A few things to consider:
> > >> >>
> > >> >> 1. Either place your Resource definition in server.xml as a
> > >> >> GlobalResource *OR* in your webapp's context.xml file.
> > >> >>
> > >> >> 2. If you have the Resource defined in the GlobalResources, that's
> >
> > >> the
> > >> >> only time you need to use a ResourceLink element in context.xml.
> > >> >>
> > >> >> 3. Drop the autoReconnect parameter in your mysql URL.  It has
> > it's
> > >> >> uses, but not in a pooled environment.
> > >> >>
> > >> >> 4. You should probably be attempting to use the path
> > >> >> java:comp/env/jdbc/TestMySQL (note the lack of a '/' before comp)
> > as
> > >> >> described in the JNDI howto on tomcat's website.  I think I saw
> > you
> > >> >> using java:/comp/env/jdbc/TestMySQL in one of your posts.
> > >> >>
> > >> >> 5. Please post relevant messages from your logs if this isn't
> > >> working.
> > >> >>
> > >> >> --David
> > >> >>
> > >> >> 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...@pidster.com> wrote:
> > >> >> >
> > >> >> >>
> > >> >> >> 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?
> > >> >> >> >
> > >> >> >>
> > >> >> >>
> > >> >> >>
> > >> >> >
> > >> >>
> > >> >>
> > >> >>
> > ---------------------------------------------------------------------
> > >> >> To start a new topic, e-mail: users@tomcat.apache.org
> > >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> > >> >>
> > >> >>
> > >> >
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> >
> > >> To start a new topic, e-mail: users@tomcat.apache.org
> > >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > >> For additional commands, e-mail: users-help@tomcat.apache.org
> > >>
> > >>
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>

Re: MySql Connector

Posted by Mohammed Zabin <jo...@gmail.com>.
In cotrast, i have installed Oracle and worked very well, but MySql didn't
work with me. I am using Connecter/J from MySql website, the beta version, I
put the jar file in the CATALINA_HOME/lib, and i add it to the CLASSPATH.
and I followed the instructions provided in Tomcat documentation, exactly,
Didn't work :(

On 7/24/07, David Smith <dn...@cornell.edu> wrote:
>
> I've never dealt with Oracle but have done a lot of MySQL installs
> without a single failure.  Your config outside of the web.xml doesn't
> look wrong in any way.
>
> You might want to put the <resource-ref> block in your web.xml as
> described in the how-to's.  It doesn't hurt and is part of the servlet
> spec.
>
> --David
>
>
> Mohammed Zabin wrote:
>
> > No, the same error, You know what David?? I put nothing in web.xml, I am
> > confused about this issue, when to use web.xml, and it might be the
> > reason
> > behind the unsuccessfull MySql Connection, I follow the same procedure I
> > followed to configure Oracle DBCP, I think it must work for MySql,
> right?
> >
> > On 7/24/07, David Smith <dn...@cornell.edu> wrote:
> >
> >>
> >> Try this variant of your code:
> >>
> >> Context initContext = new InitialContext();
> >> DataSource ds  =
> >> (DataSource)initContext.lookup("java:comp/env/jdbc/TestMySql");
> >> Connection conn = ds.getConnection();
> >>
> >> out.println("Connection Established");
> >>
> >> Essentially when you lookup java:comp/env/jdbc/TestMySql, that's the
> >> full JNDI path to the DataSource and returns a DataSource type object,
> >> not a Context type object.
> >>
> >> --David
> >>
> >> Mohammed Zabin wrote:
> >>
> >> > Ok thank you, I did the following as you have stated:
> >> >
> >> > 1. in server.xml:
> >> > <Resource name="jdbc/TestMySql" auth="Container"
> >> > type="javax.sql.DataSource"
> >> >                   maxActive="100" maxIdle="30" maxWait="10000"
> >> >                   username="root" password="exam" driverClassName="
> >> > com.mysql.jdbc.Driver"
> >> >                   url="jdbc:mysql://localhost:3306/exam"/>
> >> > 2. in context.xml
> >> > <ResourceLink global="jdbc/TestMySql" name="jdbc/TestMySql" type="
> >> > javax.sql.DataSource"/>
> >> >
> >> > 3. in my test page:
> >> >  Context initContext = new InitialContext();
> >> >  Context envContext  =
> >> > (Context)initContext.lookup("java:comp/env/jdbc/TestMySql");
> >> >  DataSource ds = (DataSource)envContext.lookup("jdbc/TestMySql");
> >> >  Connection conn = ds.getConnection();
> >> >
> >> >  out.println("Connection Established");
> >> > And i put nothing in web.xml, I have the following error:
> >> >
> >> > org.apache.jasper.JasperException: Unable to compile class for JSP:
> >> >
> >> >
> >> >
> >> > Stacktrace:
> >> >     org.apache.jasper.compiler.DefaultErrorHandler.javacError(
> >> DefaultErrorHandler.java:85)
> >> >
> >> >     org.apache.jasper.compiler.ErrorDispatcher.javacError(
> >> ErrorDispatcher.java:330)
> >> >
> >> >     org.apache.jasper.compiler.JDTCompiler.generateClass(
> >> JDTCompiler.java:415)
> >> >
> >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
> >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
> >> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
> >> >     org.apache.jasper.JspCompilationContext.compile(
> >> JspCompilationContext.java:566)
> >> >
> >> >     org.apache.jasper.servlet.JspServletWrapper.service(
> >> JspServletWrapper.java:308)
> >> >
> >> >
> >> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
> >> :320)
> >> >
> >> >     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> >> >     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >> >
> >> >
> >> >
> >> > On 7/23/07, David Smith <dn...@cornell.edu> wrote:
> >> >
> >> >>
> >> >> A few things to consider:
> >> >>
> >> >> 1. Either place your Resource definition in server.xml as a
> >> >> GlobalResource *OR* in your webapp's context.xml file.
> >> >>
> >> >> 2. If you have the Resource defined in the GlobalResources, that's
> >> the
> >> >> only time you need to use a ResourceLink element in context.xml.
> >> >>
> >> >> 3. Drop the autoReconnect parameter in your mysql URL.  It has it's
> >> >> uses, but not in a pooled environment.
> >> >>
> >> >> 4. You should probably be attempting to use the path
> >> >> java:comp/env/jdbc/TestMySQL (note the lack of a '/' before comp) as
> >> >> described in the JNDI howto on tomcat's website.  I think I saw you
> >> >> using java:/comp/env/jdbc/TestMySQL in one of your posts.
> >> >>
> >> >> 5. Please post relevant messages from your logs if this isn't
> >> working.
> >> >>
> >> >> --David
> >> >>
> >> >> 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...@pidster.com> wrote:
> >> >> >
> >> >> >>
> >> >> >> 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?
> >> >> >> >
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >
> >> >>
> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >> >>
> >> >>
> >> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: MySql Connector

Posted by David Smith <dn...@cornell.edu>.
I've never dealt with Oracle but have done a lot of MySQL installs 
without a single failure.  Your config outside of the web.xml doesn't 
look wrong in any way.

You might want to put the <resource-ref> block in your web.xml as 
described in the how-to's.  It doesn't hurt and is part of the servlet spec.

--David


Mohammed Zabin wrote:

> No, the same error, You know what David?? I put nothing in web.xml, I am
> confused about this issue, when to use web.xml, and it might be the 
> reason
> behind the unsuccessfull MySql Connection, I follow the same procedure I
> followed to configure Oracle DBCP, I think it must work for MySql, right?
>
> On 7/24/07, David Smith <dn...@cornell.edu> wrote:
>
>>
>> Try this variant of your code:
>>
>> Context initContext = new InitialContext();
>> DataSource ds  =
>> (DataSource)initContext.lookup("java:comp/env/jdbc/TestMySql");
>> Connection conn = ds.getConnection();
>>
>> out.println("Connection Established");
>>
>> Essentially when you lookup java:comp/env/jdbc/TestMySql, that's the
>> full JNDI path to the DataSource and returns a DataSource type object,
>> not a Context type object.
>>
>> --David
>>
>> Mohammed Zabin wrote:
>>
>> > Ok thank you, I did the following as you have stated:
>> >
>> > 1. in server.xml:
>> > <Resource name="jdbc/TestMySql" auth="Container"
>> > type="javax.sql.DataSource"
>> >                   maxActive="100" maxIdle="30" maxWait="10000"
>> >                   username="root" password="exam" driverClassName="
>> > com.mysql.jdbc.Driver"
>> >                   url="jdbc:mysql://localhost:3306/exam"/>
>> > 2. in context.xml
>> > <ResourceLink global="jdbc/TestMySql" name="jdbc/TestMySql" type="
>> > javax.sql.DataSource"/>
>> >
>> > 3. in my test page:
>> >  Context initContext = new InitialContext();
>> >  Context envContext  =
>> > (Context)initContext.lookup("java:comp/env/jdbc/TestMySql");
>> >  DataSource ds = (DataSource)envContext.lookup("jdbc/TestMySql");
>> >  Connection conn = ds.getConnection();
>> >
>> >  out.println("Connection Established");
>> > And i put nothing in web.xml, I have the following error:
>> >
>> > org.apache.jasper.JasperException: Unable to compile class for JSP:
>> >
>> >
>> >
>> > Stacktrace:
>> >     org.apache.jasper.compiler.DefaultErrorHandler.javacError(
>> DefaultErrorHandler.java:85)
>> >
>> >     org.apache.jasper.compiler.ErrorDispatcher.javacError(
>> ErrorDispatcher.java:330)
>> >
>> >     org.apache.jasper.compiler.JDTCompiler.generateClass(
>> JDTCompiler.java:415)
>> >
>> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
>> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
>> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
>> >     org.apache.jasper.JspCompilationContext.compile(
>> JspCompilationContext.java:566)
>> >
>> >     org.apache.jasper.servlet.JspServletWrapper.service(
>> JspServletWrapper.java:308)
>> >
>> >     
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
>> :320)
>> >
>> >     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>> >     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>> >
>> >
>> >
>> > On 7/23/07, David Smith <dn...@cornell.edu> wrote:
>> >
>> >>
>> >> A few things to consider:
>> >>
>> >> 1. Either place your Resource definition in server.xml as a
>> >> GlobalResource *OR* in your webapp's context.xml file.
>> >>
>> >> 2. If you have the Resource defined in the GlobalResources, that's 
>> the
>> >> only time you need to use a ResourceLink element in context.xml.
>> >>
>> >> 3. Drop the autoReconnect parameter in your mysql URL.  It has it's
>> >> uses, but not in a pooled environment.
>> >>
>> >> 4. You should probably be attempting to use the path
>> >> java:comp/env/jdbc/TestMySQL (note the lack of a '/' before comp) as
>> >> described in the JNDI howto on tomcat's website.  I think I saw you
>> >> using java:/comp/env/jdbc/TestMySQL in one of your posts.
>> >>
>> >> 5. Please post relevant messages from your logs if this isn't 
>> working.
>> >>
>> >> --David
>> >>
>> >> 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...@pidster.com> wrote:
>> >> >
>> >> >>
>> >> >> 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?
>> >> >> >
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To start a new topic, e-mail: users@tomcat.apache.org
>> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> >> For additional commands, e-mail: users-help@tomcat.apache.org
>> >>
>> >>
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by Mohammed Zabin <jo...@gmail.com>.
No, the same error, You know what David?? I put nothing in web.xml, I am
confused about this issue, when to use web.xml, and it might be the reason
behind the unsuccessfull MySql Connection, I follow the same procedure I
followed to configure Oracle DBCP, I think it must work for MySql, right?

On 7/24/07, David Smith <dn...@cornell.edu> wrote:
>
> Try this variant of your code:
>
> Context initContext = new InitialContext();
> DataSource ds  =
> (DataSource)initContext.lookup("java:comp/env/jdbc/TestMySql");
> Connection conn = ds.getConnection();
>
> out.println("Connection Established");
>
> Essentially when you lookup java:comp/env/jdbc/TestMySql, that's the
> full JNDI path to the DataSource and returns a DataSource type object,
> not a Context type object.
>
> --David
>
> Mohammed Zabin wrote:
>
> > Ok thank you, I did the following as you have stated:
> >
> > 1. in server.xml:
> > <Resource name="jdbc/TestMySql" auth="Container"
> > type="javax.sql.DataSource"
> >                   maxActive="100" maxIdle="30" maxWait="10000"
> >                   username="root" password="exam" driverClassName="
> > com.mysql.jdbc.Driver"
> >                   url="jdbc:mysql://localhost:3306/exam"/>
> > 2. in context.xml
> > <ResourceLink global="jdbc/TestMySql" name="jdbc/TestMySql" type="
> > javax.sql.DataSource"/>
> >
> > 3. in my test page:
> >  Context initContext = new InitialContext();
> >  Context envContext  =
> > (Context)initContext.lookup("java:comp/env/jdbc/TestMySql");
> >  DataSource ds = (DataSource)envContext.lookup("jdbc/TestMySql");
> >  Connection conn = ds.getConnection();
> >
> >  out.println("Connection Established");
> > And i put nothing in web.xml, I have the following error:
> >
> > org.apache.jasper.JasperException: Unable to compile class for JSP:
> >
> >
> >
> > Stacktrace:
> >     org.apache.jasper.compiler.DefaultErrorHandler.javacError(
> DefaultErrorHandler.java:85)
> >
> >     org.apache.jasper.compiler.ErrorDispatcher.javacError(
> ErrorDispatcher.java:330)
> >
> >     org.apache.jasper.compiler.JDTCompiler.generateClass(
> JDTCompiler.java:415)
> >
> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
> >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
> >     org.apache.jasper.JspCompilationContext.compile(
> JspCompilationContext.java:566)
> >
> >     org.apache.jasper.servlet.JspServletWrapper.service(
> JspServletWrapper.java:308)
> >
> >     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
> :320)
> >
> >     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> >     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >
> >
> >
> > On 7/23/07, David Smith <dn...@cornell.edu> wrote:
> >
> >>
> >> A few things to consider:
> >>
> >> 1. Either place your Resource definition in server.xml as a
> >> GlobalResource *OR* in your webapp's context.xml file.
> >>
> >> 2. If you have the Resource defined in the GlobalResources, that's the
> >> only time you need to use a ResourceLink element in context.xml.
> >>
> >> 3. Drop the autoReconnect parameter in your mysql URL.  It has it's
> >> uses, but not in a pooled environment.
> >>
> >> 4. You should probably be attempting to use the path
> >> java:comp/env/jdbc/TestMySQL (note the lack of a '/' before comp) as
> >> described in the JNDI howto on tomcat's website.  I think I saw you
> >> using java:/comp/env/jdbc/TestMySQL in one of your posts.
> >>
> >> 5. Please post relevant messages from your logs if this isn't working.
> >>
> >> --David
> >>
> >> 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...@pidster.com> wrote:
> >> >
> >> >>
> >> >> 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?
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: MySql Connector

Posted by David Smith <dn...@cornell.edu>.
Try this variant of your code:

Context initContext = new InitialContext();
 DataSource ds  = 
(DataSource)initContext.lookup("java:comp/env/jdbc/TestMySql");
 Connection conn = ds.getConnection();

 out.println("Connection Established");

Essentially when you lookup java:comp/env/jdbc/TestMySql, that's the 
full JNDI path to the DataSource and returns a DataSource type object, 
not a Context type object.

--David

Mohammed Zabin wrote:

> Ok thank you, I did the following as you have stated:
>
> 1. in server.xml:
> <Resource name="jdbc/TestMySql" auth="Container" 
> type="javax.sql.DataSource"
>                   maxActive="100" maxIdle="30" maxWait="10000"
>                   username="root" password="exam" driverClassName="
> com.mysql.jdbc.Driver"
>                   url="jdbc:mysql://localhost:3306/exam"/>
> 2. in context.xml
> <ResourceLink global="jdbc/TestMySql" name="jdbc/TestMySql" type="
> javax.sql.DataSource"/>
>
> 3. in my test page:
>  Context initContext = new InitialContext();
>  Context envContext  =
> (Context)initContext.lookup("java:comp/env/jdbc/TestMySql");
>  DataSource ds = (DataSource)envContext.lookup("jdbc/TestMySql");
>  Connection conn = ds.getConnection();
>
>  out.println("Connection Established");
> And i put nothing in web.xml, I have the following error:
>
> org.apache.jasper.JasperException: Unable to compile class for JSP:
>
>
>
> Stacktrace:
>     org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85) 
>
>     org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) 
>
>     org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415) 
>
>     org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
>     org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
>     org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
>     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566) 
>
>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308) 
>
>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) 
>
>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>
>
> On 7/23/07, David Smith <dn...@cornell.edu> wrote:
>
>>
>> A few things to consider:
>>
>> 1. Either place your Resource definition in server.xml as a
>> GlobalResource *OR* in your webapp's context.xml file.
>>
>> 2. If you have the Resource defined in the GlobalResources, that's the
>> only time you need to use a ResourceLink element in context.xml.
>>
>> 3. Drop the autoReconnect parameter in your mysql URL.  It has it's
>> uses, but not in a pooled environment.
>>
>> 4. You should probably be attempting to use the path
>> java:comp/env/jdbc/TestMySQL (note the lack of a '/' before comp) as
>> described in the JNDI howto on tomcat's website.  I think I saw you
>> using java:/comp/env/jdbc/TestMySQL in one of your posts.
>>
>> 5. Please post relevant messages from your logs if this isn't working.
>>
>> --David
>>
>> 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...@pidster.com> wrote:
>> >
>> >>
>> >> 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?
>> >> >
>> >>
>> >>
>> >>
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by Mohammed Zabin <jo...@gmail.com>.
Ok guys, here we are. I have define the new resource inside a <Context> tag
inside a <Host> tag, as suggested by Tomcat documentation. I removed it and
put it inside <GlobalNamingResources> tag like the following:

1. Configure naming Resource:
    inside <GlobalNamingResources> i put the following:
<Resource name="jdbc/DBTest" auth="Container" type="javax.sql.DataSource"
                          maxActive="100" maxIdle="30" maxWait="10000"
                          username="root" password="exam" driverClassName="
com.mysql.jdbc.Driver"
                      url="jdbc:mysql://localhost:3306/exam"/>

2. Inside web.xml:
<resource-ref>
      <description>Oracle Datasource example</description>
      <res-ref-name>jdbc/DBTest</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>

3. Finally, you have to connect your server to the new resource. To do that,
inside context.xml put the following:
<ResourceLink global="jdbc/DBTest" name="jdbc/DBTest" type="
javax.sql.DataSource"/>

4. Test your code as follow:

<%@ page import = "java.sql.*, javax.naming.*, javax.sql.*" %>

<%

      Context initContext = new InitialContext();
       DataSource ds  =
      (DataSource)initContext.lookup("java:comp/env/jdbc/DBTest");

       Connection conn = ds.getConnection();

       out.println("Connection Established");

%>
Tomcat 6 documentation stated that you have to put naming resource
definition inside the Context tag. And this was the problem, when i removed
it from their it worked find and the connection established successfully.

Anyways, thank you very much buddies for your time and consideration. I am
always saying that the user of this mailing list are the best developers in
the world. ;)

On 7/26/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Mohammed,
>
> Mohammed Zabin wrote:
> > If you looked at the exception you will find ClassNotFoundException at
> line
> > 66 in the generated servlet, and this occurs withing the try block, so,
> i
> > think it's a problem of Connector.
>
> You are seriously confused, here.
>
> Your code is not being compiled. Your code is not running. The fact that
> you have a try/catch block in your code is irrelevant.
>
> Why do you think that this "occurs" within the try block? Your stack
> trace does not include any references to your own code. It's simply not
> executing.
>
> And, even if this "occurred" within your try/catch block, you are
> foolishly swallowing all exceptions, meaning that you would never know
> what the problem was.
>
> > But the strange thing is that this
> > code worked fine on a normal java class???
>
> Probably because your "normal java class" actually compiled and ran.
> Something is wrong with your file, not your code.
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFGqO9T9CaO5/Lv0PARAuXgAKDBgPM+osNL0y15at28q9YITixicACgqJte
> QOgTrjE+1cqeih2be83XEww=
> =dPUB
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: MySql Connector

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mohammed,

Mohammed Zabin wrote:
> If you looked at the exception you will find ClassNotFoundException at line
> 66 in the generated servlet, and this occurs withing the try block, so, i
> think it's a problem of Connector.

You are seriously confused, here.

Your code is not being compiled. Your code is not running. The fact that
you have a try/catch block in your code is irrelevant.

Why do you think that this "occurs" within the try block? Your stack
trace does not include any references to your own code. It's simply not
executing.

And, even if this "occurred" within your try/catch block, you are
foolishly swallowing all exceptions, meaning that you would never know
what the problem was.

> But the strange thing is that this
> code worked fine on a normal java class???

Probably because your "normal java class" actually compiled and ran.
Something is wrong with your file, not your code.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGqO9T9CaO5/Lv0PARAuXgAKDBgPM+osNL0y15at28q9YITixicACgqJte
QOgTrjE+1cqeih2be83XEww=
=dPUB
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by David Smith <dn...@cornell.edu>.
Ok... I did ask for the *complete* jsp file.  Please repost.

--David

Mohammed Zabin wrote:

>It's already wrapped man, i just copied the code snippet from within <%%>
>marker ;), and for System.out, or out.println, It's still the same problem.
>If you looked at the exception you will find ClassNotFoundException at line
>66 in the generated servlet, and this occurs withing the try block, so, i
>think it's a problem of Connector. But the strange thing is that this
>code worked fine on a normal java class???
>
>On 7/26/07, David Smith <dn...@cornell.edu> wrote:
>  
>
>>1. This can't be the complete jsp code.  If it is, you need to minimally
>>wrap it in <%    %> markers to indicate it's raw java code, not
>>jsp/html.  Additionally your System.out.println() call would end up
>>going to the JVM's standard output instead of the browser.
>>
>>2. The listed exception is really secondary to the main problem
>>occurring whenever the jsp compile fails to generate a .class file.
>>There has to be an earlier exception detailing the syntax problems with
>>the jsp.
>>
>>--David
>>
>>Mohammed Zabin wrote:
>>    
>>
>>>This is my jsp code:
>>>try {
>>>         Class.forName("org.gjt.mm.mysql.Driver");
>>>         String url = "jdbc:mysql://localhost:3306/exam";
>>>         Connection con = DriverManager.getConnection(url,"root",
>>>      
>>>
>>"exam");
>>    
>>
>>>              Statement stmt = con.createStatement();
>>>              ResultSet rs = stmt.executeQuery("Select type from
>>>questions");
>>>
>>>              while( rs.next() ) {
>>>     System.out.println( rs.getString("type") );
>>>         }
>>>
>>>         } catch( Exception e ) {
>>>       }
>>>
>>>and this is what i got:
>>>
>>>*exception*
>>>
>>>org.apache.jasper.JasperException: org.apache.jasper.JasperException:
>>>Unable to load class for JSP
>>>      org.apache.jasper.servlet.JspServletWrapper.getServlet(
>>>      
>>>
>>JspServletWrapper.java:154)
>>    
>>
>>>      org.apache.jasper.servlet.JspServletWrapper.service(
>>>      
>>>
>>JspServletWrapper.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.serviceJspFile(
>>>      
>>>
>>JspServlet.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> *root cause*
>>>
>>>org.apache.jasper.JasperException: Unable to load class for JSP
>>>      org.apache.jasper.JspCompilationContext.load(
>>>      
>>>
>>JspCompilationContext.java:600)
>>    
>>
>>>      org.apache.jasper.servlet.JspServletWrapper.getServlet(
>>>      
>>>
>>JspServletWrapper.java:142)
>>    
>>
>>>      org.apache.jasper.servlet.JspServletWrapper.service(
>>>      
>>>
>>JspServletWrapper.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.serviceJspFile(
>>>      
>>>
>>JspServlet.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> *root cause*
>>>
>>>java.lang.ClassNotFoundException: org.apache.jsp.mySql_jsp
>>>      java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>>      java.security.AccessController.doPrivileged(Native Method)
>>>      java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java
>>>      
>>>
>>:134)
>>    
>>
>>>      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java
>>>      
>>>
>>:66)
>>    
>>
>>>      org.apache.jasper.JspCompilationContext.load(
>>>      
>>>
>>JspCompilationContext.java:598)
>>    
>>
>>>      org.apache.jasper.servlet.JspServletWrapper.getServlet(
>>>      
>>>
>>JspServletWrapper.java:142)
>>    
>>
>>>      org.apache.jasper.servlet.JspServletWrapper.service(
>>>      
>>>
>>JspServletWrapper.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.serviceJspFile(
>>>      
>>>
>>JspServlet.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>>
>>>Any suggestions, please?
>>>
>>>On 7/25/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
>>>
>>>      
>>>
>>>>-----BEGIN PGP SIGNED MESSAGE-----
>>>>Hash: SHA1
>>>>
>>>>Mohammed,
>>>>
>>>>Mohammed Zabin wrote:
>>>>
>>>>        
>>>>
>>>>>I have the following error:
>>>>>
>>>>>org.apache.jasper.JasperException: Unable to compile class for JSP:
>>>>>
>>>>>          
>>>>>
>>>>Uhh... you have a syntax error in your JSP code. Fix that, then we'll
>>>>get back to configuration issues. You didn't give enough information to
>>>>help with the JSP syntax error.
>>>>
>>>>- -chris
>>>>
>>>>-----BEGIN PGP SIGNATURE-----
>>>>Version: GnuPG v1.4.7 (MingW32)
>>>>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>>>
>>>>iD8DBQFGp2lm9CaO5/Lv0PARAvlRAJ45KuixS2Fy75ssMLQLwUYhA+DjOACgtiTN
>>>>nZhKt8DoIGh8UFwV+Ri6qWI=
>>>>=syvt
>>>>-----END PGP SIGNATURE-----
>>>>
>>>>---------------------------------------------------------------------
>>>>To start a new topic, e-mail: users@tomcat.apache.org
>>>>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To start a new topic, e-mail: users@tomcat.apache.org
>>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>    
>>
>
>  
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by Pid <p...@pidster.com>.
ClassNotFoundException?

<ObviousStatement>
Your JSP can't find one of the classes you refer to in the scriptlet.
</ObviousStatement>

We can't tell which one, because we don't know what's at line 266 in the 
generated java file (you could look).

Which of the classes you're using in the JSP haven't been imported at 
the top of the JSP? (possible candidates: Connection, DriverManager, 
Statement, ResultSet?)



p




Mohammed Zabin wrote:
> It's already wrapped man, i just copied the code snippet from within <%%>
> marker ;), and for System.out, or out.println, It's still the same problem.
> If you looked at the exception you will find ClassNotFoundException at line
> 66 in the generated servlet, and this occurs withing the try block, so, i
> think it's a problem of Connector. But the strange thing is that this
> code worked fine on a normal java class???
> 
> On 7/26/07, David Smith <dn...@cornell.edu> wrote:
>> 1. This can't be the complete jsp code.  If it is, you need to minimally
>> wrap it in <%    %> markers to indicate it's raw java code, not
>> jsp/html.  Additionally your System.out.println() call would end up
>> going to the JVM's standard output instead of the browser.
>>
>> 2. The listed exception is really secondary to the main problem
>> occurring whenever the jsp compile fails to generate a .class file.
>> There has to be an earlier exception detailing the syntax problems with
>> the jsp.
>>
>> --David
>>
>> Mohammed Zabin wrote:
>>> This is my jsp code:
>>> try {
>>>          Class.forName("org.gjt.mm.mysql.Driver");
>>>          String url = "jdbc:mysql://localhost:3306/exam";
>>>          Connection con = DriverManager.getConnection(url,"root",
>> "exam");
>>>               Statement stmt = con.createStatement();
>>>               ResultSet rs = stmt.executeQuery("Select type from
>>> questions");
>>>
>>>               while( rs.next() ) {
>>>      System.out.println( rs.getString("type") );
>>>          }
>>>
>>>          } catch( Exception e ) {
>>>        }
>>>
>>> and this is what i got:
>>>
>>> *exception*
>>>
>>> org.apache.jasper.JasperException: org.apache.jasper.JasperException:
>>> Unable to load class for JSP
>>>       org.apache.jasper.servlet.JspServletWrapper.getServlet(
>> JspServletWrapper.java:154)
>>>       org.apache.jasper.servlet.JspServletWrapper.service(
>> JspServletWrapper.java:320)
>>>       org.apache.jasper.servlet.JspServlet.serviceJspFile(
>> JspServlet.java:320)
>>>       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>       javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>>  *root cause*
>>>
>>> org.apache.jasper.JasperException: Unable to load class for JSP
>>>       org.apache.jasper.JspCompilationContext.load(
>> JspCompilationContext.java:600)
>>>       org.apache.jasper.servlet.JspServletWrapper.getServlet(
>> JspServletWrapper.java:142)
>>>       org.apache.jasper.servlet.JspServletWrapper.service(
>> JspServletWrapper.java:320)
>>>       org.apache.jasper.servlet.JspServlet.serviceJspFile(
>> JspServlet.java:320)
>>>       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>       javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>>  *root cause*
>>>
>>> java.lang.ClassNotFoundException: org.apache.jsp.mySql_jsp
>>>       java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>>       java.security.AccessController.doPrivileged(Native Method)
>>>       java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>       org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java
>> :134)
>>>       org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java
>> :66)
>>>       org.apache.jasper.JspCompilationContext.load(
>> JspCompilationContext.java:598)
>>>       org.apache.jasper.servlet.JspServletWrapper.getServlet(
>> JspServletWrapper.java:142)
>>>       org.apache.jasper.servlet.JspServletWrapper.service(
>> JspServletWrapper.java:320)
>>>       org.apache.jasper.servlet.JspServlet.serviceJspFile(
>> JspServlet.java:320)
>>>       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>       javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>>
>>> Any suggestions, please?
>>>
>>> On 7/25/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
>>>
>>>> -----BEGIN PGP SIGNED MESSAGE-----
>>>> Hash: SHA1
>>>>
>>>> Mohammed,
>>>>
>>>> Mohammed Zabin wrote:
>>>>
>>>>> I have the following error:
>>>>>
>>>>> org.apache.jasper.JasperException: Unable to compile class for JSP:
>>>>>
>>>> Uhh... you have a syntax error in your JSP code. Fix that, then we'll
>>>> get back to configuration issues. You didn't give enough information to
>>>> help with the JSP syntax error.
>>>>
>>>> - -chris
>>>>
>>>> -----BEGIN PGP SIGNATURE-----
>>>> Version: GnuPG v1.4.7 (MingW32)
>>>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>>>
>>>> iD8DBQFGp2lm9CaO5/Lv0PARAvlRAJ45KuixS2Fy75ssMLQLwUYhA+DjOACgtiTN
>>>> nZhKt8DoIGh8UFwV+Ri6qWI=
>>>> =syvt
>>>> -----END PGP SIGNATURE-----
>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 


Re: MySql Connector

Posted by Pid <p...@pidster.com>.
David's right, ignore my previous.


p



David Smith wrote:
> No... the exception you posted is it couldn't find the mysql_jsp.class 
> file generated by compiling the jsp file.  Do you have another stack 
> trace somewhere you haven't shown us?
> 
> Quoting from the stack trace posted below:
> 
> *root cause*
> 
> java.lang.ClassNotFoundException: org.apache.jsp.mySql_jsp
>      java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> 
> --David
> 
> Mohammed Zabin wrote:
> 
>> It's already wrapped man, i just copied the code snippet from within <%%>
>> marker ;), and for System.out, or out.println, It's still the same 
>> problem.
>> If you looked at the exception you will find ClassNotFoundException at 
>> line
>> 66 in the generated servlet, and this occurs withing the try block, so, i
>> think it's a problem of Connector. But the strange thing is that this
>> code worked fine on a normal java class???
>>
>> On 7/26/07, David Smith <dn...@cornell.edu> wrote:
>>  
>>
>>> 1. This can't be the complete jsp code.  If it is, you need to minimally
>>> wrap it in <%    %> markers to indicate it's raw java code, not
>>> jsp/html.  Additionally your System.out.println() call would end up
>>> going to the JVM's standard output instead of the browser.
>>>
>>> 2. The listed exception is really secondary to the main problem
>>> occurring whenever the jsp compile fails to generate a .class file.
>>> There has to be an earlier exception detailing the syntax problems with
>>> the jsp.
>>>
>>> --David
>>>
>>> Mohammed Zabin wrote:
>>>   
>>>> This is my jsp code:
>>>> try {
>>>>         Class.forName("org.gjt.mm.mysql.Driver");
>>>>         String url = "jdbc:mysql://localhost:3306/exam";
>>>>         Connection con = DriverManager.getConnection(url,"root",
>>>>     
>>> "exam");
>>>   
>>>>              Statement stmt = con.createStatement();
>>>>              ResultSet rs = stmt.executeQuery("Select type from
>>>> questions");
>>>>
>>>>              while( rs.next() ) {
>>>>     System.out.println( rs.getString("type") );
>>>>         }
>>>>
>>>>         } catch( Exception e ) {
>>>>       }
>>>>
>>>> and this is what i got:
>>>>
>>>> *exception*
>>>>
>>>> org.apache.jasper.JasperException: org.apache.jasper.JasperException:
>>>> Unable to load class for JSP
>>>>      org.apache.jasper.servlet.JspServletWrapper.getServlet(
>>>>     
>>> JspServletWrapper.java:154)
>>>   
>>>>      org.apache.jasper.servlet.JspServletWrapper.service(
>>>>     
>>> JspServletWrapper.java:320)
>>>   
>>>>      org.apache.jasper.servlet.JspServlet.serviceJspFile(
>>>>     
>>> JspServlet.java:320)
>>>   
>>>>      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>>      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>>
>>>> *root cause*
>>>>
>>>> org.apache.jasper.JasperException: Unable to load class for JSP
>>>>      org.apache.jasper.JspCompilationContext.load(
>>>>     
>>> JspCompilationContext.java:600)
>>>   
>>>>      org.apache.jasper.servlet.JspServletWrapper.getServlet(
>>>>     
>>> JspServletWrapper.java:142)
>>>   
>>>>      org.apache.jasper.servlet.JspServletWrapper.service(
>>>>     
>>> JspServletWrapper.java:320)
>>>   
>>>>      org.apache.jasper.servlet.JspServlet.serviceJspFile(
>>>>     
>>> JspServlet.java:320)
>>>   
>>>>      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>>      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>>
>>>> *root cause*
>>>>
>>>> java.lang.ClassNotFoundException: org.apache.jsp.mySql_jsp
>>>>      java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>>>      java.security.AccessController.doPrivileged(Native Method)
>>>>      java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>>      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java
>>>>     
>>> :134)
>>>   
>>>>      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java
>>>>     
>>> :66)
>>>   
>>>>      org.apache.jasper.JspCompilationContext.load(
>>>>     
>>> JspCompilationContext.java:598)
>>>   
>>>>      org.apache.jasper.servlet.JspServletWrapper.getServlet(
>>>>     
>>> JspServletWrapper.java:142)
>>>   
>>>>      org.apache.jasper.servlet.JspServletWrapper.service(
>>>>     
>>> JspServletWrapper.java:320)
>>>   
>>>>      org.apache.jasper.servlet.JspServlet.serviceJspFile(
>>>>     
>>> JspServlet.java:320)
>>>   
>>>>      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>>      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>>
>>>>
>>>> Any suggestions, please?
>>>>
>>>> On 7/25/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
>>>>
>>>>     
>>>>> -----BEGIN PGP SIGNED MESSAGE-----
>>>>> Hash: SHA1
>>>>>
>>>>> Mohammed,
>>>>>
>>>>> Mohammed Zabin wrote:
>>>>>
>>>>>       
>>>>>> I have the following error:
>>>>>>
>>>>>> org.apache.jasper.JasperException: Unable to compile class for JSP:
>>>>>>
>>>>>>         
>>>>> Uhh... you have a syntax error in your JSP code. Fix that, then we'll
>>>>> get back to configuration issues. You didn't give enough 
>>>>> information to
>>>>> help with the JSP syntax error.
>>>>>
>>>>> - -chris
>>>>>
>>>>> -----BEGIN PGP SIGNATURE-----
>>>>> Version: GnuPG v1.4.7 (MingW32)
>>>>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>>>>
>>>>> iD8DBQFGp2lm9CaO5/Lv0PARAvlRAJ45KuixS2Fy75ssMLQLwUYhA+DjOACgtiTN
>>>>> nZhKt8DoIGh8UFwV+Ri6qWI=
>>>>> =syvt
>>>>> -----END PGP SIGNATURE-----
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>
>>>>>
>>>>>
>>>>>       
>>>>     
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>   
>>
>>  
>>
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


Re: MySql Connector

Posted by David Smith <dn...@cornell.edu>.
No... the exception you posted is it couldn't find the mysql_jsp.class 
file generated by compiling the jsp file.  Do you have another stack 
trace somewhere you haven't shown us?

Quoting from the stack trace posted below:

 *root cause*

java.lang.ClassNotFoundException: org.apache.jsp.mySql_jsp
      java.net.URLClassLoader$1.run(URLClassLoader.java:200)

--David

Mohammed Zabin wrote:

>It's already wrapped man, i just copied the code snippet from within <%%>
>marker ;), and for System.out, or out.println, It's still the same problem.
>If you looked at the exception you will find ClassNotFoundException at line
>66 in the generated servlet, and this occurs withing the try block, so, i
>think it's a problem of Connector. But the strange thing is that this
>code worked fine on a normal java class???
>
>On 7/26/07, David Smith <dn...@cornell.edu> wrote:
>  
>
>>1. This can't be the complete jsp code.  If it is, you need to minimally
>>wrap it in <%    %> markers to indicate it's raw java code, not
>>jsp/html.  Additionally your System.out.println() call would end up
>>going to the JVM's standard output instead of the browser.
>>
>>2. The listed exception is really secondary to the main problem
>>occurring whenever the jsp compile fails to generate a .class file.
>>There has to be an earlier exception detailing the syntax problems with
>>the jsp.
>>
>>--David
>>
>>Mohammed Zabin wrote:
>>    
>>
>>>This is my jsp code:
>>>try {
>>>         Class.forName("org.gjt.mm.mysql.Driver");
>>>         String url = "jdbc:mysql://localhost:3306/exam";
>>>         Connection con = DriverManager.getConnection(url,"root",
>>>      
>>>
>>"exam");
>>    
>>
>>>              Statement stmt = con.createStatement();
>>>              ResultSet rs = stmt.executeQuery("Select type from
>>>questions");
>>>
>>>              while( rs.next() ) {
>>>     System.out.println( rs.getString("type") );
>>>         }
>>>
>>>         } catch( Exception e ) {
>>>       }
>>>
>>>and this is what i got:
>>>
>>>*exception*
>>>
>>>org.apache.jasper.JasperException: org.apache.jasper.JasperException:
>>>Unable to load class for JSP
>>>      org.apache.jasper.servlet.JspServletWrapper.getServlet(
>>>      
>>>
>>JspServletWrapper.java:154)
>>    
>>
>>>      org.apache.jasper.servlet.JspServletWrapper.service(
>>>      
>>>
>>JspServletWrapper.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.serviceJspFile(
>>>      
>>>
>>JspServlet.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> *root cause*
>>>
>>>org.apache.jasper.JasperException: Unable to load class for JSP
>>>      org.apache.jasper.JspCompilationContext.load(
>>>      
>>>
>>JspCompilationContext.java:600)
>>    
>>
>>>      org.apache.jasper.servlet.JspServletWrapper.getServlet(
>>>      
>>>
>>JspServletWrapper.java:142)
>>    
>>
>>>      org.apache.jasper.servlet.JspServletWrapper.service(
>>>      
>>>
>>JspServletWrapper.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.serviceJspFile(
>>>      
>>>
>>JspServlet.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> *root cause*
>>>
>>>java.lang.ClassNotFoundException: org.apache.jsp.mySql_jsp
>>>      java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>>      java.security.AccessController.doPrivileged(Native Method)
>>>      java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java
>>>      
>>>
>>:134)
>>    
>>
>>>      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java
>>>      
>>>
>>:66)
>>    
>>
>>>      org.apache.jasper.JspCompilationContext.load(
>>>      
>>>
>>JspCompilationContext.java:598)
>>    
>>
>>>      org.apache.jasper.servlet.JspServletWrapper.getServlet(
>>>      
>>>
>>JspServletWrapper.java:142)
>>    
>>
>>>      org.apache.jasper.servlet.JspServletWrapper.service(
>>>      
>>>
>>JspServletWrapper.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.serviceJspFile(
>>>      
>>>
>>JspServlet.java:320)
>>    
>>
>>>      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>>      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>>
>>>Any suggestions, please?
>>>
>>>On 7/25/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
>>>
>>>      
>>>
>>>>-----BEGIN PGP SIGNED MESSAGE-----
>>>>Hash: SHA1
>>>>
>>>>Mohammed,
>>>>
>>>>Mohammed Zabin wrote:
>>>>
>>>>        
>>>>
>>>>>I have the following error:
>>>>>
>>>>>org.apache.jasper.JasperException: Unable to compile class for JSP:
>>>>>
>>>>>          
>>>>>
>>>>Uhh... you have a syntax error in your JSP code. Fix that, then we'll
>>>>get back to configuration issues. You didn't give enough information to
>>>>help with the JSP syntax error.
>>>>
>>>>- -chris
>>>>
>>>>-----BEGIN PGP SIGNATURE-----
>>>>Version: GnuPG v1.4.7 (MingW32)
>>>>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>>>
>>>>iD8DBQFGp2lm9CaO5/Lv0PARAvlRAJ45KuixS2Fy75ssMLQLwUYhA+DjOACgtiTN
>>>>nZhKt8DoIGh8UFwV+Ri6qWI=
>>>>=syvt
>>>>-----END PGP SIGNATURE-----
>>>>
>>>>---------------------------------------------------------------------
>>>>To start a new topic, e-mail: users@tomcat.apache.org
>>>>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To start a new topic, e-mail: users@tomcat.apache.org
>>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>    
>>
>
>  
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by Mohammed Zabin <jo...@gmail.com>.
It's already wrapped man, i just copied the code snippet from within <%%>
marker ;), and for System.out, or out.println, It's still the same problem.
If you looked at the exception you will find ClassNotFoundException at line
66 in the generated servlet, and this occurs withing the try block, so, i
think it's a problem of Connector. But the strange thing is that this
code worked fine on a normal java class???

On 7/26/07, David Smith <dn...@cornell.edu> wrote:
>
> 1. This can't be the complete jsp code.  If it is, you need to minimally
> wrap it in <%    %> markers to indicate it's raw java code, not
> jsp/html.  Additionally your System.out.println() call would end up
> going to the JVM's standard output instead of the browser.
>
> 2. The listed exception is really secondary to the main problem
> occurring whenever the jsp compile fails to generate a .class file.
> There has to be an earlier exception detailing the syntax problems with
> the jsp.
>
> --David
>
> Mohammed Zabin wrote:
> > This is my jsp code:
> > try {
> >          Class.forName("org.gjt.mm.mysql.Driver");
> >          String url = "jdbc:mysql://localhost:3306/exam";
> >          Connection con = DriverManager.getConnection(url,"root",
> "exam");
> >               Statement stmt = con.createStatement();
> >               ResultSet rs = stmt.executeQuery("Select type from
> > questions");
> >
> >               while( rs.next() ) {
> >      System.out.println( rs.getString("type") );
> >          }
> >
> >          } catch( Exception e ) {
> >        }
> >
> > and this is what i got:
> >
> > *exception*
> >
> > org.apache.jasper.JasperException: org.apache.jasper.JasperException:
> > Unable to load class for JSP
> >       org.apache.jasper.servlet.JspServletWrapper.getServlet(
> JspServletWrapper.java:154)
> >       org.apache.jasper.servlet.JspServletWrapper.service(
> JspServletWrapper.java:320)
> >       org.apache.jasper.servlet.JspServlet.serviceJspFile(
> JspServlet.java:320)
> >       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> >       javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >
> >  *root cause*
> >
> > org.apache.jasper.JasperException: Unable to load class for JSP
> >       org.apache.jasper.JspCompilationContext.load(
> JspCompilationContext.java:600)
> >       org.apache.jasper.servlet.JspServletWrapper.getServlet(
> JspServletWrapper.java:142)
> >       org.apache.jasper.servlet.JspServletWrapper.service(
> JspServletWrapper.java:320)
> >       org.apache.jasper.servlet.JspServlet.serviceJspFile(
> JspServlet.java:320)
> >       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> >       javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >
> >  *root cause*
> >
> > java.lang.ClassNotFoundException: org.apache.jsp.mySql_jsp
> >       java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> >       java.security.AccessController.doPrivileged(Native Method)
> >       java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> >       org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java
> :134)
> >       org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java
> :66)
> >       org.apache.jasper.JspCompilationContext.load(
> JspCompilationContext.java:598)
> >       org.apache.jasper.servlet.JspServletWrapper.getServlet(
> JspServletWrapper.java:142)
> >       org.apache.jasper.servlet.JspServletWrapper.service(
> JspServletWrapper.java:320)
> >       org.apache.jasper.servlet.JspServlet.serviceJspFile(
> JspServlet.java:320)
> >       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> >       javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >
> >
> > Any suggestions, please?
> >
> > On 7/25/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
> >
> >> -----BEGIN PGP SIGNED MESSAGE-----
> >> Hash: SHA1
> >>
> >> Mohammed,
> >>
> >> Mohammed Zabin wrote:
> >>
> >>> I have the following error:
> >>>
> >>> org.apache.jasper.JasperException: Unable to compile class for JSP:
> >>>
> >> Uhh... you have a syntax error in your JSP code. Fix that, then we'll
> >> get back to configuration issues. You didn't give enough information to
> >> help with the JSP syntax error.
> >>
> >> - -chris
> >>
> >> -----BEGIN PGP SIGNATURE-----
> >> Version: GnuPG v1.4.7 (MingW32)
> >> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> >>
> >> iD8DBQFGp2lm9CaO5/Lv0PARAvlRAJ45KuixS2Fy75ssMLQLwUYhA+DjOACgtiTN
> >> nZhKt8DoIGh8UFwV+Ri6qWI=
> >> =syvt
> >> -----END PGP SIGNATURE-----
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >>
> >
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: MySql Connector

Posted by David Smith <dn...@cornell.edu>.
Oh.... and just one more thing -- use com.mysql.jdbc.Driver as 
org.gjt.mm.mysql.Driver is ancient.

--David

David Smith wrote:
> 1. This can't be the complete jsp code.  If it is, you need to 
> minimally wrap it in <%    %> markers to indicate it's raw java code, 
> not jsp/html.  Additionally your System.out.println() call would end 
> up going to the JVM's standard output instead of the browser.
>
> 2. The listed exception is really secondary to the main problem 
> occurring whenever the jsp compile fails to generate a .class file.  
> There has to be an earlier exception detailing the syntax problems 
> with the jsp.
>
> --David
>
> Mohammed Zabin wrote:
>> This is my jsp code:
>> try {
>>          Class.forName("org.gjt.mm.mysql.Driver");
>>          String url = "jdbc:mysql://localhost:3306/exam";
>>          Connection con = DriverManager.getConnection(url,"root", 
>> "exam");
>>               Statement stmt = con.createStatement();
>>               ResultSet rs = stmt.executeQuery("Select type from
>> questions");
>>
>>               while( rs.next() ) {
>>      System.out.println( rs.getString("type") );
>>          }
>>
>>          } catch( Exception e ) {
>>        }
>>
>> and this is what i got:
>>
>> *exception*
>>
>> org.apache.jasper.JasperException: org.apache.jasper.JasperException:
>> Unable to load class for JSP
>>     org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:154) 
>>
>>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320) 
>>
>>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) 
>>
>>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>
>>  *root cause*
>>
>> org.apache.jasper.JasperException: Unable to load class for JSP
>>     org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:600) 
>>
>>     org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:142) 
>>
>>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320) 
>>
>>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) 
>>
>>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>
>>  *root cause*
>>
>> java.lang.ClassNotFoundException: org.apache.jsp.mySql_jsp
>>     java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>     java.security.AccessController.doPrivileged(Native Method)
>>     java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>     org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134) 
>>
>>     org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66) 
>>
>>     org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:598) 
>>
>>     org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:142) 
>>
>>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320) 
>>
>>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) 
>>
>>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>
>>
>> Any suggestions, please?
>>
>> On 7/25/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
>>  
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Mohammed,
>>>
>>> Mohammed Zabin wrote:
>>>    
>>>> I have the following error:
>>>>
>>>> org.apache.jasper.JasperException: Unable to compile class for JSP:
>>>>       
>>> Uhh... you have a syntax error in your JSP code. Fix that, then we'll
>>> get back to configuration issues. You didn't give enough information to
>>> help with the JSP syntax error.
>>>
>>> - -chris
>>>
>>> -----BEGIN PGP SIGNATURE-----
>>> Version: GnuPG v1.4.7 (MingW32)
>>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>>
>>> iD8DBQFGp2lm9CaO5/Lv0PARAvlRAJ45KuixS2Fy75ssMLQLwUYhA+DjOACgtiTN
>>> nZhKt8DoIGh8UFwV+Ri6qWI=
>>> =syvt
>>> -----END PGP SIGNATURE-----
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>     
>>
>>   
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by David Smith <dn...@cornell.edu>.
1. This can't be the complete jsp code.  If it is, you need to minimally 
wrap it in <%    %> markers to indicate it's raw java code, not 
jsp/html.  Additionally your System.out.println() call would end up 
going to the JVM's standard output instead of the browser.

2. The listed exception is really secondary to the main problem 
occurring whenever the jsp compile fails to generate a .class file.  
There has to be an earlier exception detailing the syntax problems with 
the jsp.

--David

Mohammed Zabin wrote:
> This is my jsp code:
> try {
>          Class.forName("org.gjt.mm.mysql.Driver");
>          String url = "jdbc:mysql://localhost:3306/exam";
>          Connection con = DriverManager.getConnection(url,"root", "exam");
>               Statement stmt = con.createStatement();
>               ResultSet rs = stmt.executeQuery("Select type from
> questions");
>
>               while( rs.next() ) {
>      System.out.println( rs.getString("type") );
>          }
>
>          } catch( Exception e ) {
>        }
>
> and this is what i got:
>
> *exception*
>
> org.apache.jasper.JasperException: org.apache.jasper.JasperException:
> Unable to load class for JSP
> 	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:154)
> 	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
> 	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
> 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>  *root cause*
>
> org.apache.jasper.JasperException: Unable to load class for JSP
> 	org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:600)
> 	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:142)
> 	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
> 	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
> 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>  *root cause*
>
> java.lang.ClassNotFoundException: org.apache.jsp.mySql_jsp
> 	java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> 	java.security.AccessController.doPrivileged(Native Method)
> 	java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> 	org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)
> 	org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
> 	org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:598)
> 	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:142)
> 	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
> 	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
> 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>
> Any suggestions, please?
>
> On 7/25/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
>   
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Mohammed,
>>
>> Mohammed Zabin wrote:
>>     
>>> I have the following error:
>>>
>>> org.apache.jasper.JasperException: Unable to compile class for JSP:
>>>       
>> Uhh... you have a syntax error in your JSP code. Fix that, then we'll
>> get back to configuration issues. You didn't give enough information to
>> help with the JSP syntax error.
>>
>> - -chris
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.7 (MingW32)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iD8DBQFGp2lm9CaO5/Lv0PARAvlRAJ45KuixS2Fy75ssMLQLwUYhA+DjOACgtiTN
>> nZhKt8DoIGh8UFwV+Ri6qWI=
>> =syvt
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by Mohammed Zabin <jo...@gmail.com>.
This is my jsp code:
try {
         Class.forName("org.gjt.mm.mysql.Driver");
         String url = "jdbc:mysql://localhost:3306/exam";
         Connection con = DriverManager.getConnection(url,"root", "exam");
              Statement stmt = con.createStatement();
              ResultSet rs = stmt.executeQuery("Select type from
questions");

              while( rs.next() ) {
     System.out.println( rs.getString("type") );
         }

         } catch( Exception e ) {
       }

and this is what i got:

*exception*

org.apache.jasper.JasperException: org.apache.jasper.JasperException:
Unable to load class for JSP
	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:154)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

 *root cause*

org.apache.jasper.JasperException: Unable to load class for JSP
	org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:600)
	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:142)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

 *root cause*

java.lang.ClassNotFoundException: org.apache.jsp.mySql_jsp
	java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	java.security.AccessController.doPrivileged(Native Method)
	java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)
	org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
	org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:598)
	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:142)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


Any suggestions, please?

On 7/25/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Mohammed,
>
> Mohammed Zabin wrote:
> > I have the following error:
> >
> > org.apache.jasper.JasperException: Unable to compile class for JSP:
>
> Uhh... you have a syntax error in your JSP code. Fix that, then we'll
> get back to configuration issues. You didn't give enough information to
> help with the JSP syntax error.
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFGp2lm9CaO5/Lv0PARAvlRAJ45KuixS2Fy75ssMLQLwUYhA+DjOACgtiTN
> nZhKt8DoIGh8UFwV+Ri6qWI=
> =syvt
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: MySql Connector

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mohammed,

Mohammed Zabin wrote:
> I have the following error:
> 
> org.apache.jasper.JasperException: Unable to compile class for JSP:

Uhh... you have a syntax error in your JSP code. Fix that, then we'll
get back to configuration issues. You didn't give enough information to
help with the JSP syntax error.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGp2lm9CaO5/Lv0PARAvlRAJ45KuixS2Fy75ssMLQLwUYhA+DjOACgtiTN
nZhKt8DoIGh8UFwV+Ri6qWI=
=syvt
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by Mohammed Zabin <jo...@gmail.com>.
Ok thank you, I did the following as you have stated:

1. in server.xml:
<Resource name="jdbc/TestMySql" auth="Container" type="javax.sql.DataSource"
                   maxActive="100" maxIdle="30" maxWait="10000"
                   username="root" password="exam" driverClassName="
com.mysql.jdbc.Driver"
                   url="jdbc:mysql://localhost:3306/exam"/>
2. in context.xml
<ResourceLink global="jdbc/TestMySql" name="jdbc/TestMySql" type="
javax.sql.DataSource"/>

3. in my test page:
  Context initContext = new InitialContext();
  Context envContext  =
(Context)initContext.lookup("java:comp/env/jdbc/TestMySql");
  DataSource ds = (DataSource)envContext.lookup("jdbc/TestMySql");
  Connection conn = ds.getConnection();

  out.println("Connection Established");
And i put nothing in web.xml, I have the following error:

org.apache.jasper.JasperException: Unable to compile class for JSP:



Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



On 7/23/07, David Smith <dn...@cornell.edu> wrote:
>
> A few things to consider:
>
> 1. Either place your Resource definition in server.xml as a
> GlobalResource *OR* in your webapp's context.xml file.
>
> 2. If you have the Resource defined in the GlobalResources, that's the
> only time you need to use a ResourceLink element in context.xml.
>
> 3. Drop the autoReconnect parameter in your mysql URL.  It has it's
> uses, but not in a pooled environment.
>
> 4. You should probably be attempting to use the path
> java:comp/env/jdbc/TestMySQL (note the lack of a '/' before comp) as
> described in the JNDI howto on tomcat's website.  I think I saw you
> using java:/comp/env/jdbc/TestMySQL in one of your posts.
>
> 5. Please post relevant messages from your logs if this isn't working.
>
> --David
>
> 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...@pidster.com> wrote:
> >
> >>
> >> 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?
> >> >
> >>
> >>
> >>
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: MySql Connector

Posted by David Smith <dn...@cornell.edu>.
A few things to consider:

1. Either place your Resource definition in server.xml as a 
GlobalResource *OR* in your webapp's context.xml file.

2. If you have the Resource defined in the GlobalResources, that's the 
only time you need to use a ResourceLink element in context.xml.

3. Drop the autoReconnect parameter in your mysql URL.  It has it's 
uses, but not in a pooled environment.

4. You should probably be attempting to use the path 
java:comp/env/jdbc/TestMySQL (note the lack of a '/' before comp) as 
described in the JNDI howto on tomcat's website.  I think I saw you 
using java:/comp/env/jdbc/TestMySQL in one of your posts.

5. Please post relevant messages from your logs if this isn't working.

--David

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...@pidster.com> wrote:
>
>>
>> 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?
>> >
>>
>>
>>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: MySql Connector

Posted by Pid <p...@pidster.com>.
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...@pidster.com> wrote:
>>
>> 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...@pidster.com> wrote:
>> >>
>> >> 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?
>> >> >
>> >>
>> >>
>> >>
>> >
>>
>>
>>
> 


Re: MySql Connector

Posted by Mohammed Zabin <jo...@gmail.com>.
Thank you, what about testing the connection, i am afraid that the test code
is the reason:

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"??

On 7/22/07, Pid <p...@pidster.com> wrote:
>
> 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...@pidster.com> wrote:
> >>
> >> 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?
> >> >
> >>
> >>
> >>
> >
>
>
>

Re: MySql Connector

Posted by Pid <p...@pidster.com>.
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...@pidster.com> wrote:
>>
>> 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?
>> >
>>
>>
>>
> 


Re: MySql Connector

Posted by Mohammed Zabin <jo...@gmail.com>.
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...@pidster.com> wrote:
>
> 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?
> >
>
>
>

Re: MySql Connector

Posted by Pid <p...@pidster.com>.
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?
> 


Re: tomcat 6 and virtual donmains

Posted by Hassan Schroeder <ha...@gmail.com>.
On 7/22/07, Miren Urkixo <mi...@tinieblas.com> wrote:
> and can you help me for making the same configuration into tomcat 6?
> i am reading the doc and i dont load the configurationç

I'm not sure what that last comment means, but go here:

   <http://tomcat.apache.org/tomcat-6.0-doc/>

:: and read the User Guide sections 8,9, and 24, and you should be able
to get your configurations sorted out. :-)

If not, post the relevant parts of the revised config files and whatever
error messages you're getting...

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat 6 and virtual donmains

Posted by Miren Urkixo <mi...@tinieblas.com>.
and can you help me for making the same configuration into tomcat 6?
i am reading the doc and i dont load the configurationç
thanks

----- Original Message ----- 
From: "Hassan Schroeder" <ha...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Sunday, July 22, 2007 3:46 PM
Subject: Re: tomcat 6 and virtual donmains


> On 7/22/07, Miren Urkixo <mi...@tinieblas.com> wrote:
> .
>> i am working using tomcat 5.0.XX and my virtual host configuration i made
>> into the server.xml file.
>> i am testing tomcat 6 i am  configuring the virtualhost into the server 
>> xml
>> and it says me always, whe i try to load the page, that the conext 
>> doesn't
>> exist.
>> can you help me?
>> my configuration into the server.xml is:
>
> just plain wrong -- Resource params are done quite differently now.
> You should read the documentation for the version you're using, not
> just copy things from the configuration of previous versions. :-)
>
> And putting Context elements in server.xml is strongly discouraged.
>
> HTH,
> -- 
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
> 



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat 6 and virtual donmains

Posted by Hassan Schroeder <ha...@gmail.com>.
On 7/22/07, Miren Urkixo <mi...@tinieblas.com> wrote:
.
> i am working using tomcat 5.0.XX and my virtual host configuration i made
> into the server.xml file.
> i am testing tomcat 6 i am  configuring the virtualhost into the server xml
> and it says me always, whe i try to load the page, that the conext doesn't
> exist.
> can you help me?
> my configuration into the server.xml is:

just plain wrong -- Resource params are done quite differently now.
You should read the documentation for the version you're using, not
just copy things from the configuration of previous versions. :-)

And putting Context elements in server.xml is strongly discouraged.

HTH,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


tomcat 6 and virtual donmains

Posted by Miren Urkixo <mi...@tinieblas.com>.
HEllo
i have one great problem.
i am working using tomcat 5.0.XX and my virtual host configuration i made 
into the server.xml file.
i am testing tomcat 6 i am  configuring the virtualhost into the server xml 
and it says me always, whe i try to load the page, that the conext doesn't 
exist.
can you help me?
my configuration into the server.xml is:

<Host name="pruebas.domain.info" debug="0" appBase="webapps/domain" 
unpackWARs="true" autoDeploy="true" xmlValidation="false" 
xmlNamespaceAware="false">
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" 
prefix="domain_log." suffix=".txt" timestamp="true"/>
<Context path="/domain" docBase="" reloadable="true" crossContext="true">
<Resource name="jdbc/db" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/db">
<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://127.0.0.1:5432/db</value>
</parameter>
<parameter>
<name>username</name>
<value>user</value>
</parameter>
<parameter>
<name>password</name>
<value/>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>20</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>300</value>
</parameter>
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
</ResourceParams>
</Context>
</Host> 



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org