Re: JDK 7 support with mysql-connector-java-5.1.23
Posted by: upendra rai
Date: February 22, 2013 05:10AM

import java.sql.*;
import javax.sql.*;

public class demo{

public static void main(String args[]){
String dbtime;
String dbUrl = "jdbc:mysql:localhost:3306/login";
String dbClass = "com.mysql.jdbc.Driver";
String query = "Select * FROM login";

try {

Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection (dbUrl);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {
dbtime = rs.getString(1);
System.out.println(dbtime);
} //end while

con.close();
} //end try

catch(ClassNotFoundException e) {
e.printStackTrace();
}

catch(SQLException e) {
e.printStackTrace();
}

} //end main

} //end class




getting the errors
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at demo.main(demo.java:14)

Options: ReplyQuote


Subject
Written By
Posted
Re: JDK 7 support with mysql-connector-java-5.1.23
February 22, 2013 05:10AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.