Forums Register Login

JSP and MySQL

+Pie Number of slices to send: Send
Hello,

I am trying to write a JSP program that will connect to my database.
I use NetBeans and I have created a database in MySQL called School.

I looked at some sample codes online and did not understand the following;


1. Class.forName("org.gjt.mm.mysql.Driver");
What does the "org.gjt.mm.mysql.Driver" stand for? Other programs I looked at just have "Driver".

2.dbconn = DriverManager.getConnection("jdbc:mysql://localhost/mydatabase";
Here, i guess the program is trying to connect to the database but my question is how do you configure Tomcat to work with MySQL?

Thanks you very much for your concern.

Sen Aff.
+Pie Number of slices to send: Send
Hi
here is your answer go through this link to get your query clarified.





Using the MySQL
JDBC Driver
+Pie Number of slices to send: Send
Hello,

I followed the instruction but I had a runtime exception.

this is what is in my code:
....
String URL = "jdbc:mysql:localhost:8084/Practice/School?user=root&password=password";
.....
try {
con = DriverManager.getConnection(URL);
......

and this is the error i had:org.apache.jasper.JasperException: Exception in JSP: /ShowStu.jsp:51

48: Connection con = null;
49:
50: try {
51: con = DriverManager.getConnection(URL);


root cause
javax.servlet.ServletException: No suitable driver found for jdbc:mysql:localhost:8084/Practice/School?user=root&password=password

Thanks for your help and time.

Sen Aff.
+Pie Number of slices to send: Send
According to http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html:


...the jar file for your JDBC driver should be installed in $CATALINA_HOME/common/lib



This requirement will be the same for other versions of Tomcat.
+Pie Number of slices to send: Send
Hi Kevin,

I tried to open the link you gave but it was invalid
http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html:

I am using the Tomcat that comes bundled with NetBeans and I loaded the driver in the Libraries folder under my project folder.

Thanks a lot for your help.

Sen Aff.
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
Hi,

I have followed the instructions you gave me but i
still get the same error.

org.apache.jasper.JasperException: An exception occurred processing JSP page /ShowStu.jsp at line 52

49:
50:
51: try {
52: con = DriverManager.getConnection(URL, user, pd);
53:


Can anyone please help me out? Thanks.

Sen Aff.
+Pie Number of slices to send: Send
 

Originally posted by Sen Aff:

....
String URL = "jdbc:mysql:localhost:8084/Practice/School?user=root&password=password";
.....
try {
con = DriverManager.getConnection(URL);
......

and this is the error i had:org.apache.jasper.JasperException: Exception in JSP: /ShowStu.jsp:51

48: Connection con = null;
49:
50: try {
51: con = DriverManager.getConnection(URL);


root cause
javax.servlet.ServletException: No suitable driver found for jdbc:mysql:localhost:8084/Practice/School?user=root&password=password



The URL you are using is incorrect. Check the MySQL JDBC driver docs for the correct format for the url.

[ June 01, 2007: Message edited by: Kevin Mukhar ]
[ June 01, 2007: Message edited by: Kevin Mukhar ]
+Pie Number of slices to send: Send
Hello,

Thanks a lot for the help. I find out that the URL was not
properly written and I had to download a new driver....
mysql-connector-java-3.1.11-bin.

It works now.

Thanks once again.

sen Aff.
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1431 times.
Similar Threads
MySQL is driving me nuts
JFaceDbc and MySQL
loading driver in JSP
mysql driver classpath How to plz?
Connection JSP with MySql
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:01:40.