[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

JDBC and MySQL can't get a connection

Posted on 2003-02-28
5
Medium Priority
?
382 Views
Last Modified: 2010-04-01
Can anyone out there help me get JDBC driver for MySQL setup? I've downloaded the driver and un tar ed it. I copied the .jar file to my /WEB-INF/lib inside the root folder of my JSP files. I've restarted my tomcat server. If I look a the logs under /var/tomcat4/logs/localhost_test_log.txt I see something to the effect of deploy JAR /WEB-INF/lib/Mysql.driver.name.jar and the log shows no errors.

Now when I try to make a connection to the databa I can't.
When I use out.println("exception: " + ex.getMessage() );
I get "exception: No suitable driver ".
Can anyone help?

I've pasted the entire page I'm using to try to test JDBC below.

____________________________________________________
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%
Connection conn = null;
Statement st = null;
ResultSet rs = null;

try {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
     conn = DriverManager.getConnection("jdbc.mysql://localhost/storycircle?user=root&password=fake");
     st = conn.createStatement();
     rs = st.executeQuery("select * from story");
     while(rs.next()) {

%>
<%= rs.getString("ID") %>
<%= rs.getString("story") %>

<%

}

} catch (Exception ex) {
     ex.printStackTrace();
     
      out.println("exception: " + ex.getMessage() );

     }
%>



</body>
</html>
0
Comment
Question by:Xcalabers
  • 3
5 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 8043779
please put MySQL jdbc jar file into /var/tomcat4/common/lib
and make sure the jar file is readable by everybody, like -rw-rw-r-- (you must see 3 "r")
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8043792
there is problem in your connection string, try this:
conn = DriverManager.getConnection("jdbc:mysql://localhost/storycircle", "root", "fake");
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 800 total points
ID: 8044023
please notice the differece of "jdbc:mysql" instead of "jdbc.mysql"
0
 
LVL 92

Expert Comment

by:objects
ID: 8044958
connection string should be:

"jdbc:mysql://localhost/storycircle:root:fake"
0
 

Author Comment

by:Xcalabers
ID: 8045554
What a big diffrance 1 little dot makes! Thank you for your help. I'm bran new to java and this has been frustrating me for several days.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Virtualization software lets you run different versions of Windows, Ubuntu Linux and other versions of Linux all at the same time, rather than running each one directly from your computer's hard drive.
Data security in the cloud is very much like a security in an on-premises data center - only without costs for maintaining facilities and computer hardware.
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
Suggested Courses

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question