View Full Version : JSP - MySQL Connection Problem - Class.forName()

07-19-2004, 08:42 PM

I've been trying to make a connection to the MySQL database for a while now. My code is below. For some reason, it does not get past the first line. I always get this exception:

org.apache.jasper.JasperException: com.mysql.jdbc.Driver

I went on the web and all the sites say that this is the proper driver so I'm very confused on why it's not working. As you can see the rest of my code is commented out so I haven't even gotten to the username & password.

Any help would be greatly appreciated.




//Connection con = DriverManager.getConnection("jdbc:mysql:///main", "root", mypassword);

//java.sql.Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSIT IVE,
// ResultSet.CONCUR_UPDATABLE); // Enable traversing of the Result Set
//ResultSet rs = null;

07-20-2004, 05:58 AM
Wasn't sure what the jdbc driver was so did some searching and found it stands for Java Database Connectivity. Since it involves java would you need to run the Java Runtime Environment that is available via your site manager. It also sounds from some post I found on other forums that the error can occur when Tomcat is not installed. That is also avaiable via the Site Manager. It may be simply the Tomcat since some of the stuff I read on it mentioned that the error refelcted not being able to find Tomcat in order to compile the program.

I'm not familiar with this and it might help you out more to read the links and post I found. I did a google search with the errror in full and it came up with quite a bit of stuff.

07-20-2004, 06:14 PM
Thanks for the fast reply. I looked at the other postings but all of them talk about connection strings which would be my next step. I have both Tomcat and the Jave Runtime Environment installed so I have no idea what to do next. It seems like nobody else is having problems with this which is puzzling me even more. I'll check Google again but I think it has something to do with my configuration which I have no idea how to do. I thought Westhost did that part...

09-22-2004, 03:01 PM
As a matter of fact, guys, I was about to post a message about the exact same problem. I had posted in the "General Discussion" area, but, at jalal's urging, I will repost it here. Since you seem to be having the same problem, I don't see why to create a new thread.

EDIT: I just realized that the previous message was posted months ago... hopefully someone will pick up on this... or else I'll open another thread!! Don't make me.... :lol:

Here's a copy of my original post:


Hey, y'all.... I need some help here, and hopefully a good soul (or a bad soul in a good mood) will help me out! :?

I am trying to access Mysql using JDBC. All I get is a "Connection refused" message. I have Linux installed in one of my home PCs, and my small application works just fine. I even installed the exact same version of Mysql, Java and Tomcat that WestHost offers, just to keep things as compatible as possible. Setting up Tomcat was fine, but I can't get the darned JDBC connection to work.

To better isolate and research this problem, I created a very small Java program, whose only purpose in life is to connect to the database and display the contents of a test table, and I am changing all possible settings in Mysql, trying to make it work, and so far nothing, nada, zilch... same error over and over again - so it's nothing on Tomcat. I tested the same thing in my home Linux box, and it works fine.

The fact that the program works on my local machine indicates that some configuration is out of whack in my WestHost VPS, and I can tell you right off the bat what the problem is NOT:

- It's not bypassing the "skip-networking" in the my.cnf file. I already tried that.
- User and password are checked and correct ( I am assuming that Mysql and Tomcat are in localhost, which I think it's safe to say is a fact )
- It's not any other connection information - the driver name is correct, the classpath is initialized properly.
- Oh and by the way, I DID upload the JDBC driver and its location is in the classpath
- TCP/IP access is NOT enabled in my Mysql, but since the connection is coming from localhost, that shouldn't be necessary. Besides, PHP can access Mysql fine, which shows that Mysql is responding to a connection originated locally.

So, this is not really a generic JDBC/Mysql question, it's a question regarding JDBC/Mysql in WestHost.

I contacted their user support, and even though they were quick to respond and corteous, JDBC connections "are not supported at this time", as the manual so eloquently puts it. :cry:


Thanks :)