| Author |
SQLException: [Microsoft][ODBC Driver Manager]
|
Glenn Castro
Ranch Hand
Joined: Aug 24, 2003
Posts: 78
|
|
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()); } } }
|
Glenn Castro<br />Sun Certified Web Component Developer
|
 |
Jamie Robertson
Ranch Hand
Joined: Jul 09, 2001
Posts: 1879
|
|
|
sounds like your computer can't find the datasource named COFFEEBREAK. Make sure this ODBC datasource is set up on your computer and that it is spelled the same as in your java app.
|
 |
Mr. C Lamont Gilbert
Ranch Hand
Joined: Oct 05, 2001
Posts: 1170
|
|
What OS are you using? I will assume win2K. It has to be windows. "COFFEEBREAK" is the name of the datasource not the database file name. to set up a datasource go to control panel. Open administrative tools. Double click "Data Sources(ODBC)" go to system DSN tab. choose add. Pick the microsoft access driver. give it the datasource name COFFEEBREAK. choose create, and give it whatever filename you wish and put it where you like. You are all set.
|
 |
 |
|
|
subject: SQLException: [Microsoft][ODBC Driver Manager]
|
|
|