This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes ClassNotFoundException generated! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "ClassNotFoundException generated!" Watch "ClassNotFoundException generated!" New topic
Author

ClassNotFoundException generated!

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi all,
I have written the foll code. But it generated the execption
ClassNotFoundException .What may be the reason??
import java.sql.*;
public class Select {
public static void main(String args[]) {
String url = "jdbc dbc:mrai";
Connection con;
String createString;
createString = "create table COFFEES " + "(COF_NAME VARCHAR(32), " +
"SUP_ID INTEGER, " + "PRICE FLOAT, " + "SALES INTEGER, " + "TOTAL INTEGER)";
Statement stmt;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); }
try {
con = DriverManager.getConnection(url, "scott", "tiger");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage()); }
}
}
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
Usually, these type of errors is caused by your incorrect setting in your Classpath variables. May sure you have the class path set up correctly.
 
Have you checked out Aspose?
 
subject: ClassNotFoundException generated!
 
It's not a secret anymore!