You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Massimiliano PASQUALONI <ma...@data-processing.it> on 2007/05/09 17:59:48 UTC

Msql Connector/J

Hi everybody!
 
I'ved downloaded mysql-connector-java-5.1.0.zip.
 
I'ved put the mysql-connector-java-5.1.0-bin.jar in
C:\Programmi\Java\jre1.6.0_01\lib and I'ved set the %CALSSPATH% on the same
directory.
 
 
I'ved create a jsp page:
 
 
<%@ page import="java.sql.*" %>
<%
String connectionURL =
"jdbc:mysql://localhost:3306/bi?user=USER;password=PASSWORD";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<html><body>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "", "");
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM  TABLE WHERE username='ciao' and
password='ciao' and Abilitato = 1");
while (rs.next()) {
out.println(rs.getString("username")+"<br>");
}
rs.close();
%>
 
 
Tomcat send me an 500 error:
 
 
type Exception report

message 

description The server encountered an internal error () that prevented it
from fulfilling this request.

exception 

org.apache.jasper.JasperException: Exception in JSP: /prova.jsp:14



11: <html><body>

12: 

13: <%

14: Class.forName("com.mysql.jdbc.Driver").newInstance();

15: connection = DriverManager.getConnection(connectionURL, "", "");

16: statement = connection.createStatement();

17: rs = statement.executeQuery("SELECT * FROM ANAG_UTENTI WHERE
username='ciao' and password='ciao' and Abilitato = 1");





Stacktrace:

	
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWra
pper.java:467)

	
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
71)

	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)

	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



root cause 

javax.servlet.ServletException: com.mysql.jdbc.Driver

	
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextI
mpl.java:846)

	
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:779)

	org.apache.jsp.prova_jsp._jspService(prova_jsp.java:79)

	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

	
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
28)

	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)

	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



root cause 

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

	
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1359)

	
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1205)

	
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)

	
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)

	java.lang.ClassLoader.loadClassInternal(Unknown Source)

	java.lang.Class.forName0(Native Method)

	java.lang.Class.forName(Unknown Source)

	org.apache.jsp.prova_jsp._jspService(prova_jsp.java:57)

	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

	
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
28)

	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)

	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



note The full stack trace of the root cause is available in the Apache
Tomcat/5.5.23 logs.

 
 
It's the connector don't work?
 
 
Thanks!!!
 

Massimiliano PASQUALONI

Data Processing S.r.l.
Reparto EDP
S.S. 100 BA-TA Km 18
c/o "IL BARICENTRO" 
torre D
70010 CASAMASSIMA (BA)

RE: Msql Connector/J

Posted by David Short <ds...@san.rr.com>.
Unzip the connector and place the .jar file in the common\lib directory or
in the webapps\**appname**\WEB-INF\lib directory. 

-----Original Message-----
From: Massimiliano PASQUALONI
[mailto:massimiliano.pasqualoni@data-processing.it] 
Sent: Wednesday, May 09, 2007 9:00 AM
To: users@tomcat.apache.org
Subject: Msql Connector/J

Hi everybody!
 
I'ved downloaded mysql-connector-java-5.1.0.zip.
 
I'ved put the mysql-connector-java-5.1.0-bin.jar in
C:\Programmi\Java\jre1.6.0_01\lib and I'ved set the %CALSSPATH% on the same
directory.
 
 
I'ved create a jsp page:
 
 
<%@ page import="java.sql.*" %>
<%
String connectionURL =
"jdbc:mysql://localhost:3306/bi?user=USER;password=PASSWORD";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<html><body>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "", ""); statement =
connection.createStatement(); rs = statement.executeQuery("SELECT * FROM
TABLE WHERE username='ciao' and password='ciao' and Abilitato = 1"); while
(rs.next()) { out.println(rs.getString("username")+"<br>");
}
rs.close();
%>
 
 
Tomcat send me an 500 error:
 
 
type Exception report

message 

description The server encountered an internal error () that prevented it
from fulfilling this request.

exception 

org.apache.jasper.JasperException: Exception in JSP: /prova.jsp:14



11: <html><body>

12: 

13: <%

14: Class.forName("com.mysql.jdbc.Driver").newInstance();

15: connection = DriverManager.getConnection(connectionURL, "", "");

16: statement = connection.createStatement();

17: rs = statement.executeQuery("SELECT * FROM ANAG_UTENTI WHERE
username='ciao' and password='ciao' and Abilitato = 1");





Stacktrace:

	
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWra
pper.java:467)

	
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
71)

	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)

	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



root cause 

javax.servlet.ServletException: com.mysql.jdbc.Driver

	
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextI
mpl.java:846)

	
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:779)

	org.apache.jsp.prova_jsp._jspService(prova_jsp.java:79)

	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

	
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
28)

	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)

	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



root cause 

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

	
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1359)

	
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1205)

	
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)

	
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)

	java.lang.ClassLoader.loadClassInternal(Unknown Source)

	java.lang.Class.forName0(Native Method)

	java.lang.Class.forName(Unknown Source)

	org.apache.jsp.prova_jsp._jspService(prova_jsp.java:57)

	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

	
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
28)

	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)

	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



note The full stack trace of the root cause is available in the Apache
Tomcat/5.5.23 logs.

 
 
It's the connector don't work?
 
 
Thanks!!!
 

Massimiliano PASQUALONI

Data Processing S.r.l.
Reparto EDP
S.S. 100 BA-TA Km 18
c/o "IL BARICENTRO" 
torre D
70010 CASAMASSIMA (BA)



---------------------------------------------------------------------
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: R: Msql Connector/J

Posted by Pid <p...@pidster.com>.
Massimiliano PASQUALONI wrote:
> Guy, 
> 
> 	I've already configured mysql. It correctly work whit Apache and
> PHP, I need only to join it whit Tomcat.
> 
> The David/s suggestion work fine, if I place the jar file in WEB-INF\lib
> directory, Tomcat try to connect.
> 
> But, even though I specify the user and password in the connectionURL,
> connectionURL =
> "jdbc:mysql://localhost:3306/bi?user=myuser;password=mypassword", my Tomcat
> return: "Error 500: javax.servlet.ServletException: Access denied for user
> ''@'localhost' (using password: NO)"

Strongly recommend that you use a JNDI Datasource - it handles 
connection pooling for you and will provide a *much* better base to 
build your app on.

In the examples in the JNDI Datasource doc, you supply the username and 
password as attributes, not in the URL.

> I the JNDI Datasource HOW-TO (
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> ) I'ved see that I need to configure the server.xml and the web.xml files.
> But, I belive, it's a particular specific use of Tomcat and MySql and I
> don't need that, I just want a connection whit my application an mysql, not
> from the Application Server and Mysql...

The config required is minimal, and offers speed improvements amongst 
other things.  Retrieving a DataSource from JNDI is much quicker than 
creating a new one every time you want to hit the database.

It's pretty standard to do this, and more unusual not to, in my experience.


rgds

p



> P.S. hearty congratulations, I think you are best comunity on the world,
> swift, accurate and efficient!
> 
> 
> 
> Thanks!
> 
> 
> 
> 
> 
> 
> Massimiliano Pasqualoni
> http://www.pasqualoni.it
> 
> 
> 
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Scanned with Copfilter Version 0.83beta3a (ProxSMTP 1.4)
> AntiVirus: ClamAV 0.88.4/3224 - Wed May  9 17:25:29 2007
> by Markus Madlener @ http://www.copfilter.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: R: Msql Connector/J

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

Massimiliano,

Massimiliano PASQUALONI wrote:
> But, even though I specify the user and password in the connectionURL,
> connectionURL =
> "jdbc:mysql://localhost:3306/bi?user=myuser;password=mypassword", my Tomcat
> return: "Error 500: javax.servlet.ServletException: Access denied for user
> ''@'localhost' (using password: NO)"

"Using password: NO" means that the password is not being sent correctly
to the database server. You have an error in your URL: the ";" should be
a "&", just like a regular URL. That's probably why the password is
being ignored. In fact, I'll bet that the username being used is
"myuser;password=mypassword".

I agree with Pid's recommendation to use JNDI for your database
connection. If you do that, you can use the same connection pool for
Tomcat's realm authentication and your own application as well, instead
of separate sets of connections. (If you setup a JDBCRealm, Tomcat
manages either a single connection or a separate set of connections for
authentication. I've seen misconfigurations where the application can
connect to the database but the realm cannot. Oops!)

- -chris

> 
> :-(
> 
> I the JNDI Datasource HOW-TO (
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> ) I'ved see that I need to configure the server.xml and the web.xml files.
> But, I belive, it's a particular specific use of Tomcat and MySql and I
> don't need that, I just want a connection whit my application an mysql, not
> from the Application Server and Mysql...
> 
> 
> P.S. hearty congratulations, I think you are best comunity on the world,
> swift, accurate and efficient!
> 
> 
> 
> Thanks!
> 
> 
> 
> 
> 
> 
> Massimiliano Pasqualoni
> http://www.pasqualoni.it
> 
> 
> 
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Scanned with Copfilter Version 0.83beta3a (ProxSMTP 1.4)
> AntiVirus: ClamAV 0.88.4/3224 - Wed May  9 17:25:29 2007
> by Markus Madlener @ http://www.copfilter.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
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGQw4i9CaO5/Lv0PARAgucAJ0cPOJt9BCbcRgLb67hafQ8N/7DwgCfQqj6
YNRwHUtyL5WAVcj1srNE+Js=
=02Hj
-----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


R: Msql Connector/J

Posted by Massimiliano PASQUALONI <ma...@data-processing.it>.
Guy, 

	I've already configured mysql. It correctly work whit Apache and
PHP, I need only to join it whit Tomcat.

The David/s suggestion work fine, if I place the jar file in WEB-INF\lib
directory, Tomcat try to connect.

But, even though I specify the user and password in the connectionURL,
connectionURL =
"jdbc:mysql://localhost:3306/bi?user=myuser;password=mypassword", my Tomcat
return: "Error 500: javax.servlet.ServletException: Access denied for user
''@'localhost' (using password: NO)"

:-(

I the JNDI Datasource HOW-TO (
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
) I'ved see that I need to configure the server.xml and the web.xml files.
But, I belive, it's a particular specific use of Tomcat and MySql and I
don't need that, I just want a connection whit my application an mysql, not
from the Application Server and Mysql...


P.S. hearty congratulations, I think you are best comunity on the world,
swift, accurate and efficient!



Thanks!






Massimiliano Pasqualoni
http://www.pasqualoni.it



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Scanned with Copfilter Version 0.83beta3a (ProxSMTP 1.4)
AntiVirus: ClamAV 0.88.4/3224 - Wed May  9 17:25:29 2007
by Markus Madlener @ http://www.copfilter.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: Msql Connector/J

Posted by David Smith <dn...@cornell.edu>.
Non-existent??  huh... wierd.  I could have sworn I saw a lot of it on 
the company site (www.mysql.com).

As to the OP, the classpath environment variable is ignored by tomcat's 
default startup script and for very good reason. 

Given the manner in which the jsp is attempting to get a database 
connection, WEB-INF/lib of the web application is an excellent place for 
the mysql driver jar.  I would start there.  If the OP wants to use 
tomcat's container managed database pooling, it should be moved to the 
common/lib directory of tomcat's install dir as suggested by another 
responder.

For further details, the tomcat website has information on the 
classloader hierarchy and how it works as well as details on setting up 
container managed pooling.

--David

Martin Gainty wrote:
> you and sven need to search thru the mostly nonexistent MySQL 
> documentation on how to
> start MYSQLd
> create a user (other than null@localhost)
> create DATABASE
> create TABLE in DATABASE
> turn on INNODB
>
> the MySQL documentation is pretty much nonexistent so you and sven 
> should have lots of fun
>
> M-
>
> GL
> M--
> This email message and any files transmitted with it contain confidential
> information intended only for the person(s) to whom this email message is
> addressed.  If you have received this email message in error, please 
> notify
> the sender immediately by telephone or email and destroy the original
> message without making a copy.  Thank you.
>
> ----- Original Message ----- From: "Massimiliano PASQUALONI" 
> <ma...@data-processing.it>
> To: <us...@tomcat.apache.org>
> Sent: Wednesday, May 09, 2007 11:59 AM
> Subject: Msql Connector/J
>
>
>> Hi everybody!
>>
>> I'ved downloaded mysql-connector-java-5.1.0.zip.
>>
>> I'ved put the mysql-connector-java-5.1.0-bin.jar in
>> C:\Programmi\Java\jre1.6.0_01\lib and I'ved set the %CALSSPATH% on 
>> the same
>> directory.
>>
>>
>> I'ved create a jsp page:
>>
>>
>> <%@ page import="java.sql.*" %>
>> <%
>> String connectionURL =
>> "jdbc:mysql://localhost:3306/bi?user=USER;password=PASSWORD";
>> Connection connection = null;
>> Statement statement = null;
>> ResultSet rs = null;
>> %>
>> <html><body>
>> <%
>> Class.forName("com.mysql.jdbc.Driver").newInstance();
>> connection = DriverManager.getConnection(connectionURL, "", "");
>> statement = connection.createStatement();
>> rs = statement.executeQuery("SELECT * FROM  TABLE WHERE 
>> username='ciao' and
>> password='ciao' and Abilitato = 1");
>> while (rs.next()) {
>> out.println(rs.getString("username")+"<br>");
>> }
>> rs.close();
>> %>
>>
>>
>> Tomcat send me an 500 error:
>>
>>
>> type Exception report
>>
>> message
>>
>> description The server encountered an internal error () that 
>> prevented it
>> from fulfilling this request.
>>
>> exception
>>
>> org.apache.jasper.JasperException: Exception in JSP: /prova.jsp:14
>>
>>
>>
>> 11: <html><body>
>>
>> 12:
>>
>> 13: <%
>>
>> 14: Class.forName("com.mysql.jdbc.Driver").newInstance();
>>
>> 15: connection = DriverManager.getConnection(connectionURL, "", "");
>>
>> 16: statement = connection.createStatement();
>>
>> 17: rs = statement.executeQuery("SELECT * FROM ANAG_UTENTI WHERE
>> username='ciao' and password='ciao' and Abilitato = 1");
>>
>>
>>
>>
>>
>> Stacktrace:
>>
>>
>> org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWra 
>>
>> pper.java:467)
>>
>>
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3 
>>
>> 71)
>>
>>
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
>>
>> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>>
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>
>>
>>
>> root cause
>>
>> javax.servlet.ServletException: com.mysql.jdbc.Driver
>>
>>
>> org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextI 
>>
>> mpl.java:846)
>>
>>
>> org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp 
>>
>> l.java:779)
>>
>> org.apache.jsp.prova_jsp._jspService(prova_jsp.java:79)
>>
>> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
>>
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>
>>
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3 
>>
>> 28)
>>
>>
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
>>
>> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>>
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>
>>
>>
>> root cause
>>
>> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
>>
>>
>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav 
>>
>> a:1359)
>>
>>
>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav 
>>
>> a:1205)
>>
>>
>> org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)
>>
>>
>> org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
>>
>> java.lang.ClassLoader.loadClassInternal(Unknown Source)
>>
>> java.lang.Class.forName0(Native Method)
>>
>> java.lang.Class.forName(Unknown Source)
>>
>> org.apache.jsp.prova_jsp._jspService(prova_jsp.java:57)
>>
>> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
>>
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>
>>
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3 
>>
>> 28)
>>
>>
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
>>
>> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>>
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>
>>
>>
>> note The full stack trace of the root cause is available in the Apache
>> Tomcat/5.5.23 logs.
>>
>>
>>
>> It's the connector don't work?
>>
>>
>> Thanks!!!
>>
>>
>> Massimiliano PASQUALONI
>>
>> Data Processing S.r.l.
>> Reparto EDP
>> S.S. 100 BA-TA Km 18
>> c/o "IL BARICENTRO"
>> torre D
>> 70010 CASAMASSIMA (BA)
>>
>
>
> ---------------------------------------------------------------------
> 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
>


-- 
David Smith
Network Operations Supervisor
Department of Entomology
Cornell University
2132 Comstock Hall
Ithaca, NY 14853
Phone: (607) 255-9571
Fax: (607) 255-0940


---------------------------------------------------------------------
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: Msql Connector/J

Posted by Martin Gainty <mg...@hotmail.com>.
you and sven need to search thru the mostly nonexistent MySQL documentation 
on how to
start MYSQLd
create a user (other than null@localhost)
create DATABASE
create TABLE in DATABASE
turn on INNODB

the MySQL documentation is pretty much nonexistent so you and sven should 
have lots of fun

M-

GL
M--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "Massimiliano PASQUALONI" <ma...@data-processing.it>
To: <us...@tomcat.apache.org>
Sent: Wednesday, May 09, 2007 11:59 AM
Subject: Msql Connector/J


> Hi everybody!
>
> I'ved downloaded mysql-connector-java-5.1.0.zip.
>
> I'ved put the mysql-connector-java-5.1.0-bin.jar in
> C:\Programmi\Java\jre1.6.0_01\lib and I'ved set the %CALSSPATH% on the 
> same
> directory.
>
>
> I'ved create a jsp page:
>
>
> <%@ page import="java.sql.*" %>
> <%
> String connectionURL =
> "jdbc:mysql://localhost:3306/bi?user=USER;password=PASSWORD";
> Connection connection = null;
> Statement statement = null;
> ResultSet rs = null;
> %>
> <html><body>
> <%
> Class.forName("com.mysql.jdbc.Driver").newInstance();
> connection = DriverManager.getConnection(connectionURL, "", "");
> statement = connection.createStatement();
> rs = statement.executeQuery("SELECT * FROM  TABLE WHERE username='ciao' 
> and
> password='ciao' and Abilitato = 1");
> while (rs.next()) {
> out.println(rs.getString("username")+"<br>");
> }
> rs.close();
> %>
>
>
> Tomcat send me an 500 error:
>
>
> type Exception report
>
> message
>
> description The server encountered an internal error () that prevented it
> from fulfilling this request.
>
> exception
>
> org.apache.jasper.JasperException: Exception in JSP: /prova.jsp:14
>
>
>
> 11: <html><body>
>
> 12:
>
> 13: <%
>
> 14: Class.forName("com.mysql.jdbc.Driver").newInstance();
>
> 15: connection = DriverManager.getConnection(connectionURL, "", "");
>
> 16: statement = connection.createStatement();
>
> 17: rs = statement.executeQuery("SELECT * FROM ANAG_UTENTI WHERE
> username='ciao' and password='ciao' and Abilitato = 1");
>
>
>
>
>
> Stacktrace:
>
>
> org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWra
> pper.java:467)
>
>
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
> 71)
>
>
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
>
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>
>
> root cause
>
> javax.servlet.ServletException: com.mysql.jdbc.Driver
>
>
> org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextI
> mpl.java:846)
>
>
> org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
> l.java:779)
>
> org.apache.jsp.prova_jsp._jspService(prova_jsp.java:79)
>
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
>
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
> 28)
>
>
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
>
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>
>
> root cause
>
> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
>
>
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
> a:1359)
>
>
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
> a:1205)
>
>
> org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)
>
>
> org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
>
> java.lang.ClassLoader.loadClassInternal(Unknown Source)
>
> java.lang.Class.forName0(Native Method)
>
> java.lang.Class.forName(Unknown Source)
>
> org.apache.jsp.prova_jsp._jspService(prova_jsp.java:57)
>
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
>
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
> 28)
>
>
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
>
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>
>
> note The full stack trace of the root cause is available in the Apache
> Tomcat/5.5.23 logs.
>
>
>
> It's the connector don't work?
>
>
> Thanks!!!
>
>
> Massimiliano PASQUALONI
>
> Data Processing S.r.l.
> Reparto EDP
> S.S. 100 BA-TA Km 18
> c/o "IL BARICENTRO"
> torre D
> 70010 CASAMASSIMA (BA)
> 


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