Hi,
It's my first time to use
JDBC and I got the following message on running a simple JDBC code.
SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
How can I resolve this problem. Can anyone teach me how to setup the database and what should i put on the following code:
import java.sql.Connection;
import java.sql.*;
public class CreateCoffees {
public static void main(
String args[]) {
String url = "jdbc

dbc:COFFEEBREAK"; //COFFEEBREAK is the name of the DB
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, "sa", "");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}