Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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:
  #1  
Old September 5th, 2001, 06:19 AM
fol fol is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 1 fol User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
jsp(java)/mysql connection

Hello
i have downloaded sql which i seem to connect to fine using doc command.Does any one know how to connect to mysql using JAVA or preferably JSP? only connection code please without the quries or html .
I have a piece of code below which i have tried to use unsuccessfully.
I get error message.

<%
try
{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
}
catch (Exception E)
{
System.err.println("Unable to load driver.");
E.printStackTrace();
}
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:8080/PROJ");
Statement statement = conn.createStatement();
String sql = "SELECT * FROM LOGINS";
ResultSet rs = statement.executeQuery(sql);
while(rs.next()) {
%>
<tr>
<td><%= rs.getString("customerID") %></td>
<td><%= rs.getString("username") %></td>
<td><%= rs.getString("password") %></td>
<td><%= rs.getString("logintype") %></td>
</tr>
<% } %>

<% if(statement != null)
statement.close();
if(conn != null)
conn.close();
%>

Reply With Quote
  #2  
Old September 5th, 2001, 08:48 AM
Rehan Malik Rehan Malik is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Posts: 0 Rehan Malik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
First:
- Did you download the JDBC Driver for mm.mysql? If not, you need to do so and add it to your classpath

Second:
- MySQL does not typically run on port 8080, that is for the web server. It usually runs on port 3306 by default.

Third:
- I might be wrong here but are you sure that you're using the right URL to connect? "jdbc:mysql://localhost:8080/PROJ" doesn't seem right to me.

Fourth:
- It doesn't specify anywhere your username and password so there is no authentication done. From what little I've worked with (on MySQL), you need to provide this information to connect.

hope this helps in helping your problem

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > jsp(java)/mysql connection

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap