Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes Help...Problem with Class.forName( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Help...Problem with Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  " Watch "Help...Problem with Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  " New topic
Author

Help...Problem with Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Travis Gibson
Ranch Hand

Joined: Oct 17, 2000
Posts: 100
Ranchers,
I feel silly for evening asking this question but here it goes.
I keep getting the following message:
CreateCoffees.java:50: cannot resolve symbol
symbol: method forName (java.lang.String)
location: class Class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
^
Why???
/*
* @(#)CreateCoffees.java1.2 99/04/23
*/
import java.sql.*;
// Create the Coffee Table.
public class CreateCoffees {
public static void main(String args[]) {
String url = "jdbc dbc:CafeJava";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME varchar(32), " +
"SUP_ID int, " +
"PRICE float, " +
"SALES int, " +
"TOTAL int)";
Statement stmt;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Class.forName("C:\Program Files\JavaSoft\JRE\1.3\bin\Jdbc0dbc.dll");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,
"Admin", "duke1");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}


Regards,<BR>Travis M. Gibson, SCJP<BR>Java Developer<BR>www.travismgibson.com<BR>travis@travismgibson.com
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
This is almost always a classpath issue. Check your classpath and make sure that it is set up correctly.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
GeeCON Prague 2014
 
subject: Help...Problem with Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");