Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie

0 views
Skip to first unread message

Gavin Metcalfe

unread,
Aug 13, 2001, 4:24:37 PM8/13/01
to
I am trying to make a simple applet to connect to my mysql database. I have
downloaded a driver from http://mmmysql.sourceforge.net/ but am not sure how
I use it. Can anyone point me in the right direction. A bit of sample code
would be great.

Cheers Gav


Jason

unread,
Aug 13, 2001, 9:21:56 PM8/13/01
to
I have not been able to get this damn driver to work either.

SUPPOSEDLY you update your %CLASSPATH% variable to reference the path to the
.jar file and reboot. I have rebooted my computer like 25 times today.

The jdbc:odbc bridge works fine "out of the box" by referencing a DSN, but I
keep getting a classNotFound exception with the mySQL jdbc driver. I am also
asking for someone with experience to help out. I haven't heard from anyone
with the answer yet.

Anyway, the code you use looks something like this (in JSP):

---

<%@ page import = "java.sql.*,
java.util.*,
java.awt.*"
errorPage = "error.jsp" %>
<%
Connection conn = null;
Statement stmt = null;
String getSQL = null;
String address = null;

getSQL = "SELECT customerAddress " +
"FROM thetable " +
"WHERE thecolumn = 'theCriteria';";

Class.forName("org.gjt.mm.mysql.Driver");
conn = DriverManager.getConnection("jdbc:mysql://databasename","uid","pass");
stmt = conn.createStatement();

rs = stmt.executeQuery(getSQL);

if (rs.next()) {
// do something with the resultset
address = rs.getString("customerAddress");
}

// ... etc

if (rs!=null) rs.close();
if (stmt!=null) stmt.close();
if (conn!=null) conn.close();

%>

Here is the address: <%=address%>

--------

Like I said, it's all theory, because I haven't gotten it to work because of
this lame driver problem. :( I get this over and over and over and over...

-------------------------


java.lang.ClassNotFoundException: Unable to load class org.gjt.mm.mysql.Driver
at
org.apache.jasper.servlet.JasperLoader.findClass(JasperLoader.java:223)
at
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:147)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at
_0002fentryform_0002ejspentryform_jsp_136._jspService(_0002fentryform_0002ejspe
ntryform_jsp_136.java:96)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:
130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:
282)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Aj
p12ConnectionHandler.java:166)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)


~)ason

Gavin Metcalfe

unread,
Aug 14, 2001, 7:39:28 AM8/14/01
to
Right, I got the same problem at first I have now added the file
specifically to the class path. I am writing an applet so I am not sure if
you can do this in JSP (Never done any JSP), now it is finding the driver
but failing on handshake. I will keep you posted.

Cheers Gav

"Jason" <ja...@toTheLeft.net> wrote in message
news:9l9ufk$er5$1...@bob.news.rcn.net...

Nils O. Selådal

unread,
Aug 19, 2001, 7:16:11 PM8/19/01
to
Jason wrote:

> I have not been able to get this damn driver to work either.
>
> SUPPOSEDLY you update your %CLASSPATH% variable to reference the path to
> the
> .jar file and reboot. I have rebooted my computer like 25 times today.

The wonders of Windows...

If you make an application, you can starti it by doing e.g.
java -classpath c:\path\to\mysql.jar.

It however seems that you use JSP and Tomcat...
Place the mm driver in the lib directory under your webapp, e.g
c:\tomcat\webapps\mywebapp\WEB-INF\lib\

--
Nils O. Selåsdal

0 new messages