|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
jsp, jdbc driver, mysql
I have installed and run tomcat successfully, and have also installed mysql successfully. I have also downloaded the mysql driver and set the classpath as instructed:
SET CLASSPATH=%CLASSPATH%;C:\jdk1.3.0_02\bin;C:\jdk1.3.0_02\lib\mm.mysql-2.0.11\mm.mysql-2.0.11-bin.jar In spite of all this, I am still getting the following error: javax.servlet.ServletException: No suitable driver...etc...etc... Here is the code for my test page, which I am running from the tomcat examples directory: <%@ page language="java" import="java.sql.*" %> <body> <% Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection("jdbc:mysql//localhost/TestDb01?user=myname&password=mypassword"); Statement stmt = conn.createStatement(); // change this as per your requirements String query = "select * from er_tb_fieldchoices"; ResultSet myResultSet = stmt.executeQuery(query); if (myResultSet != null) { while (myResultSet.next()) { // specify the field name String name = myResultSet.getString("User"); %> <%= name %> <br> <% } } stmt.close(); conn.close(); %> Thanks in advance for any thoughts you can offer. |
|
#2
|
|||
|
|||
|
Not sure if it will help or not, but I have heard of some problems sending the username and pass on the query string. try this instead:
Code:
try {
String host = "localhost";
String port = "";//whatever port you are running on.
String dbName = "TestDb01";
String uid = "myName";
String pw = "myPassword";
Class.forName("org.gjt.mm.mysql.Driver");
String dbType = "jdbc:mysql:";
String url = dbType + "//" + host + ":" + port + "/" + dbName;
conn = DriverManager.getConnection(url, uid, pw);
/* more code */
}
catch (ClassNotFoundException cnfe) { cnfe.printStackTrace(); }
catch (SQLException sqle) { sqle.printStackTrace(); }
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > jsp, jdbc driver, mysql |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|