Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava 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:
  #1  
Old June 30th, 2005, 07:27 PM
hodhod hodhod is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 1 hodhod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 51 sec
Reputation Power: 0
Angry installing jdbc connector/j help please

Hi all,
i have MySQL Server runing on my machine fine but i am having problem when i tried to compile my j2me programm and i think the problem to with MySQL Connector/j since the compiler doesn't recognized all the classes such as Statement, Connection, ResultSet and DriverManager.

I have copied 'mysql-connector-java-3.1.10-bin.jar' file to my JAVA_HOME folder which is C:\j2sdk1.4.2_07\jre\lib\ext and i create new CLASSPATH with the full path to the .jar file but still my compiler doesn't like it any help please???????????!!!!!!!!

Reply With Quote
  #2  
Old July 5th, 2005, 08:14 PM
infamous-online infamous-online is offline
Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 404 infamous-online User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 24 m 44 sec
Reputation Power: 7
you place that file under your tomcat directory under the common/lib directory. restart your server and try it. let me know the outcome.
Comments on this post
gertcuppens agrees!
__________________
Apache Expert

Reply With Quote
  #3  
Old July 9th, 2005, 04:40 PM
lonewolf27 lonewolf27 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: South Africa
Posts: 21 lonewolf27 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 27 sec
Reputation Power: 0
You're in luck! I recently decided to play around with connector/j and mysql for a project i needed to research for, and after about 3 hrs of stress trying to get it to work, my console FINALLY printed "connected successfully" and i jumped for joy!

Anyways, not too sure where your problem might be [if at all you've fixed it!] without seeing your code, but i'll give you a little checklist that seems to fix most problems:

1. make sure you have a recent version of the java jdk
2. same goes for the connector/j
3. not too serious where you put the "mysql-connector-java-3.1.8-bin.jar" file, just make sure your classpath is good. Eg: CLASSPATH=.;c:\mysql-connector-java-3.1.8-bin.jar [yes, with the .; in front if there is nothing else, but you seem to have this right ]
4. the last part, and most critical it seems, would be the code. not sure what you did in your .java file, but here's an example of what worked for me:

import java.sql.*;
public static void main(String[] args){
Connection con = null;
Statement st = null;
ResultSet rs = null;
String url = "jdbc:mysql://localhost:3306/mysql"; //where 3306 is the port, localhost is address of DB, and mysql is name of the database you wanna use...
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(url, "user", "pass");
st = con.createStatement();
rs = st.executeQuery("select * from db"); //where db is the table name...
if (rs.next()) System.out.println(rs.getString(1));
if (rs.next()) System.out.println(rs.getInt(2)); //etc...
if (con != null) con.close(); //same for st and rs...
}
catch(Exception e){System.out.println(e.getMessage());}
}

Try that and lemme know...hope it helps

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > installing jdbc connector/j help please


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