?
Solved

JDBC and MySQL can't get a connection

Posted on 2003-02-28
5
Medium Priority
?
379 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

762 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