|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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???????????!!!!!!!! |
|
#2
|
|||
|
|||
|
you place that file under your tomcat directory under the common/lib directory. restart your server and try it. let me know the outcome.
__________________
Apache Expert |
|
#3
|
|||
|
|||
|
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 ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > installing jdbc connector/j help please |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|