SunQuest
           Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old February 4th, 2002, 07:52 AM
vincent9999 vincent9999 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 8 vincent9999 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old February 4th, 2002, 12:45 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
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(); }

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > jsp, jdbc driver, mysql


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway