•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 391,593 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,665 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 19290 | Replies: 3
![]() |
| |
•
•
Join Date: Feb 2003
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I am trying to set up a java server page and mysql. I have installed jdk and all of the neccessary tools and drivers. I am using Tomcat for the servlet container. I have also set up an account with a password on mysql. I think that the only issue that stands in the way is setting the classpath for the database driver. What jar file is it supposed to point to? This is what I have downloaded for a driver.
mysql-connector-java-2.0.14
This is the classpath I have set
CLASSPATH=C:/mm.mysql-connector-2.0.6.1.jar;C:\tomcat\common\lib\servlet
.jar;C:\tomcat\common\lib\mm.mysql-connector-2.0.6.1.jar;C:\tomcat\common\lib\my
sql-connector-java-2.0.14-bin.jar;.
I am not sure if I am still missing anything. I still get this error. I can compile .jsp files with no problem but when I try to access a database it just wont work. What is the correct jar file it needs to point to? This one
mm.mysql-connector-2.0.6.1.jar or this one
mysql-connector-java-2.0.14-bin.jar;. I am really getting confused here.
This is the error I recieve.
org.apache.jasper.JasperException: org.gjt.mm.mysql.Driver
Could someone help? I would like the full classpath in detail if possible.
Below is the code I am trying to use.
<%@ page language="java" import="java.sql.*" contentType="text/html;charset=KSC5601" %>
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://localhost/wrox";
Connection Conn=DriverManager.getConnection(url,"rob","ropo2121");
Statement stmt = Conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from books");
if (!rs.next()) {
out.println("empty~~~");
} else {
out.println(rs.getString(1));
}
stmt.close();
Conn.close();
%>
mysql-connector-java-2.0.14
This is the classpath I have set
CLASSPATH=C:/mm.mysql-connector-2.0.6.1.jar;C:\tomcat\common\lib\servlet
.jar;C:\tomcat\common\lib\mm.mysql-connector-2.0.6.1.jar;C:\tomcat\common\lib\my
sql-connector-java-2.0.14-bin.jar;.
I am not sure if I am still missing anything. I still get this error. I can compile .jsp files with no problem but when I try to access a database it just wont work. What is the correct jar file it needs to point to? This one
mm.mysql-connector-2.0.6.1.jar or this one
mysql-connector-java-2.0.14-bin.jar;. I am really getting confused here.
This is the error I recieve.
org.apache.jasper.JasperException: org.gjt.mm.mysql.Driver
Could someone help? I would like the full classpath in detail if possible.
Below is the code I am trying to use.
<%@ page language="java" import="java.sql.*" contentType="text/html;charset=KSC5601" %>
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://localhost/wrox";
Connection Conn=DriverManager.getConnection(url,"rob","ropo2121");
Statement stmt = Conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from books");
if (!rs.next()) {
out.println("empty~~~");
} else {
out.println(rs.getString(1));
}
stmt.close();
Conn.close();
%>
•
•
Join Date: Oct 2007
Posts: 13
Reputation:
Rep Power: 1
Solved Threads: 0
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://localhost/database_name?user=user_name&password=type_password&useUnicode=true&characterEncoding=8859_1";
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
.
.
.
.
%>
like that it goes.........
Hop it will help u.......
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://localhost/database_name?user=user_name&password=type_password&useUnicode=true&characterEncoding=8859_1";
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
.
.
.
.
%>
like that it goes.........
Hop it will help u.......
•
•
•
•
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://localhost/database_name?user=user_name&password=type_password&useUnicode=true&characterEncoding=8859_1";
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
.
.
.
.
%>
like that it goes.........
Hop it will help u.......
That is the old MySQL driver, and is only still present in the distribution for backwards compatability. Use, as the first reply indicated, com.mysql.jdbc.Driver instead of org.gjt.mm.mysql.Driver
Edit: Also, remove all of that scriptlet stuff out of that JSP. It does not belon there. Put it into a bean or some other external object. Anywhere but as a scriptlet in the JSP.
Edit Again:
And DAMN, I didn't notice that this was some ancient post reanimated every two years.
nikhita. The OP made the post four years ago. And the last reply before yours (and mine, unfortunately) was two years ago. I don't think anybody is waiting on an answer anymore.
Last edited by masijade : Oct 4th, 2007 at 8:05 am. Reason: additional info. marked above
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
Similar Threads
- How to Connect MySQL from JSP Page (JSP)
- JSP shopping cart (JSP)
- connecting jsp with mysql database (JSP)
- JSP Hosting (JSP)
- Cant get a free web host for JSP & MYSQL (JSP)
Other Threads in the JSP Forum
- Previous Thread: uploading file using JSP to mysql database
- Next Thread: <c:if problem.



Hybrid Mode