LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   JSP and MySQL - unable to load JDBC driver (https://www.linuxquestions.org/questions/programming-9/jsp-and-mysql-unable-to-load-jdbc-driver-480424/)

jun_tuko 09-04-2006 06:41 PM

JSP and MySQL - unable to load JDBC driver
 
hello gurus,
need your help once again. i am trying to program using jsp to do simple data insertion and extraction to and from mysql database. i have some .jsp files that works at my school but when i transferred them here at my home linux box, it's giving:

Unable to load MySQL JDBC driver.
SQLException: No suitable driver SQLState: 08001 VendorError: 0


here's what i have done:
1) previously installed apache, mysql, and php. my linux distro is fedora core 4. i know mysql works because i have programs written in php to write and read data to and from mysql.
2) i just installed tomcat. it shows my html files that i put in its webapss folder so i know tomcat works.
3) i have java sdk installed. i know it works too because i can run java programs.
4) when doing research, i read somewhere that i need to copy jdbc driver on to my tomcat_folder/server/lib. i have copied two (2) drivers there. a)mm.mysql-2.0.8-bin.jar from my books cd. b) mysql-connector-java-3.1.13-bin.jar from mysql's website (j connector).

in my jsp program, here are the lines i got from my school versus and my edited version. both of them does not work on my linux machine.

School (works at school but not at home):
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection conn = DriverManager.getConnection ( "jdbc:mysql://repost.insttech.wa.edu/jtuko", "jtuko", "password" );

Edited:
Class.forName("com.mysql.jdbc.Driver").newInstance();
**or the from school**
Connection conn = DriverManager.getConnection ( "jdbc:mysql://localhost/jtuko", "jtuko", "password" );

im am not sure what the url is supposed to be in connection line. my understanding is jdbc:mysql:// should be followed by nameofserver/nameofdatabase then username and password.

please help.
thanks.
jun

paulsm4 09-04-2006 10:11 PM

Hi -

Two suggestions:

1. Try copying the two jar files to your common/lib directory (and *definitely* reboot Tomcat!)

2. Try looking in your tomcat /log directory: it might give you some better clues as to the exact problem.

'Hope that helps .. PSM

jun_tuko 09-05-2006 11:02 AM

hi paul,
thank you!!!!! i copied the 2 drivers to /tomcat/common/lib folder and it works!!!! also, i tried using:

Class.forName("org.gjt.mm.mysql.Driver").newInstance();

and

Class.forName("com.mysql.jdbc.Driver").newInstance();

and both of them work as well. so thank you for the suggestions.

have a great day!

jun


All times are GMT -5. The time now is 08:19 AM.