This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes What's wrong with this code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "What Watch "What New topic
Author

What's wrong with this code?

rogelio uribe
Greenhorn

Joined: Aug 01, 2001
Posts: 14
Hi there:
I'm testing some examples from the book "JDBC Database Access with Java", and I'm getting this error message when I try to run it:
SQLExpection:[Microsoft][Administrador de controladores ODBC]El nombre del origen de datos no se encontro y no se especifico ningun controlador predeterminado.
SQLExpection:[Microsoft][ODBC Drivers Administrator]The name of the data source was not found and a predeterminated driver was not especified.
The code of the program is:

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");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
System.out.println("trying to connect"}"); /* after this line the error is generated. */
con = DriverManager.getConnection(url, "", "");
System.out.println("statement");
stmt = con.createStatement();
stmt.executeUpdate(createString);

stmt.close();
con.close();

} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
The database "cafeJava.mdb", is located on the same source directory that this program. Can anybody help me, please?.
Thanks in advance.


Roger
rogelio uribe
Greenhorn

Joined: Aug 01, 2001
Posts: 14
Jack the Snack, thank you, I missed that point. Everything is running correctly.
Regards,
Roger
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What's wrong with this code?
 
Similar Threads
ClassNotFoundException generated!
SQLException: [Microsoft][ODBC Driver Manager]
Basic Doubt
Class.forName() for drive using Oracle 8i
Access to the Oracle database using Java Applets