SunQuest
 
           MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 21st, 2004, 09:44 AM
VenProg VenProg is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Venezuela
Posts: 2 VenProg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
mysql and java

Hi everyone,

im a newbie here, so im gonna introduce myself and then begin with my problem, My name is Jose, im from Venezuela. im a College student and again, im a newbie when it comes to java.

anyway, i know a thing or two. i was hoping that i could find some information here about connecting to mysql databases with java, using jdbc or whatever. if any of you could help me, ill thank you for ever!

hey, any kind of information for newbies will do, is a project im doing for my uncle's company.

well, i've no more to say but thanks for reading and for your atention!

Bye, Jose.

Reply With Quote
  #2  
Old March 24th, 2004, 06:48 AM
Talar's Avatar
Talar Talar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Sweden
Posts: 3 Talar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm having a similar problem using the JDBC driver available at URL

Try going there and install the ConnectorJ driver. I haven't got this working properly myself so if you succeed I'd be grateful if you told me about it.

Reply With Quote
  #3  
Old March 24th, 2004, 12:26 PM
VenProg VenProg is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Venezuela
Posts: 2 VenProg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
yeah sure... but i still havent success in my problem. bye!

Reply With Quote
  #4  
Old March 29th, 2004, 08:20 AM
Faizal Faizal is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Singapore
Posts: 4 Faizal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile eclispe

I'm not sure whether tis will fix ur problem..
paste this executable jar file: mysql-connector-java-3.0.9-stable-bin
into C:\...\Tomcat 4.1\common\lib

Reply With Quote
  #5  
Old May 1st, 2004, 05:42 AM
kiwiburger kiwiburger is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 kiwiburger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wink connecting to mysql db from java

have a look at the code I have pasted
It worked for me
I will try to upload the book I got it from in pdf format
hope this helps you
Kiwiburger
package mysqltest;
import java.sql.*;
/**
* <p>Title: MySQL Database Connection </p>
* <p>Description: This was the first attempt to connect to a MySQL database</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author Kiwiburger
* @version 1.0
*/
public class msql_test {
Connection connection;
private void displaySQLErrors(SQLException e) {
System.out.println("SQLException: " + e.getMessage());
System.out.println("SQLState: " + e.getSQLState());
System.out.println("VendorError: " + e.getErrorCode());
}
public void connectToDB() {
try {
//change the user name and password to yours
String userName = "username";
String password = "password";
//change the database name to your db
String url = "jdbc:mysql://localhost/databasename";
Class.forName ("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}catch(SQLException e) {
displaySQLErrors(e);
}catch(ClassNotFoundException cnfe){
System.err.println("Unable to find and load driver: " + cnfe.getException());
System.exit(1);
}
}
public void executeSQL() {
try {
Statement statement = connection.createStatement();
//change the table name to your table
ResultSet rs = statement.executeQuery("select * from tablename;");

//I have multiple strings in the table I was using for the example...just
//add or change as you need them
while (rs.next()) {
System.out.println(rs.getString(1) + " " + rs.getString(2) + " " + rs.getString(3) +
" " + rs.getString(4) + " " + rs.getString(5)
+ " " + rs.getString(6) + " " + rs.getString(7)
+ " " + rs.getString(8) + " " + rs.getString(9)
+ " " + rs.getString(10) + " " + rs.getString(11)
+ " " + rs.getString(12) + " " + rs.getString(13)
+ " " + rs.getString(14) + " " + rs.getString(15));
}
rs.close();
statement.close();
connection.close();
}catch(SQLException e) {
displaySQLErrors(e);
}
}

public static void main(String[] args) {
msql_test mysql_test = new msql_test();
mysql_test.connectToDB();
mysql_test.executeSQL();
}
}
//hope this helps....it works for me
//email me at paulstewart@maxnet.co.nz if it worked

Last edited by kiwiburger : May 1st, 2004 at 05:44 AM. Reason: adding email address

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > mysql and java


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