I think my questions are stupid for most of you, but I am totally new to
JDBC, so please forgive me asking the stupid questions. I want to
connect to my MS-Access running under WIn2000 from Java application
using JDBC. I want to use JDBC-ODBC bridge which came with JDK1.3.
After I execute a statement
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
I execute a following statement. I have test.mdb file.
Connection con = DriverManager.getConnection("jdbc:odbc:test");
Then I get following errors.
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name
not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:2458)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize
(JdbcOdbcConnection.java:320)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:163)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:199)
Could somebody tell me how to connect MS-Access? I am running on my PC
(locally). And When I try to connect, does Access have to running?
Thanks in advance.
You need to create an ODBC data source on the Windows machine where
this code runs. See "data sources" in Administrative Tools.
--
Vriendelijke groet,
René Pijlman <rpij...@spamcop.net>
Wat wil jij leren?
http://www.leren.nl/
From Data Source in Administrative Tools, I picked User DNS tab and I
selected MS Access Database.
Then I clicked Configure and I clicked Select.
After that, I chose E:\db\test.mdb.
Is this a correct way to create data source?
I still get following error messages.
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name
not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:2458)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize
(JdbcOdbcConnection.java:320)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:163)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:199)
Thanks in advance.
In article <u5gomt0tm5fc18ht7...@4ax.com>,
reage...@de.nieuwsgroep says...
pick the button that says add.
Then select Microsoft Access Driver (*.mdb)
Then click finish
Now enter any Name that you would like to call the DataBase. This is what
you put in the DataBase Name field.
Next in the DataBase section, click on select, and pick your .mdb file.
This is how I did it.
<stil...@ryuji.net> wrote in message
news:MPG.15d616f04...@news-byoa.prodigy.net...
Check your setup with this documentation:
http://home-1.worldonline.nl/~bmc88/java/jdbc/
http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/bridge.doc.html
<stil...@ryuji.net> wrote in message
news:MPG.15d616f04...@news-byoa.prodigy.net...
: Thanks for the response. I created the data sourse. What I did was
: >
Statement stm = con.createStatement();
String val = "INSERT INTO testTable VALUES(\"111\", \"John\", \"New
York\", \"123-4567\");";
stm.executeUpdate(val);
However, I got folling errors. Why it says "Too few parpameters"?
Could anybody tell me what wrong is?
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few
parameters. Expected 4.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2494)
at sun.jdbc.odbc.JdbcOdbcStatement.execute
(JdbcOdbcStatement.java:314)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate
(JdbcOdbcStatement.java:264)
And what JDBC book do you recommend?
Thanks in advance.
What does your table look like?
>And what JDBC book do you recommend?
http://java.sun.com/docs/books/jdbc/
Very thorough.
My table has four columns which are following.
ID (text), name (text), address (text), phone (text)
Thanks
Try this,
String val = "insert into testTable(id, name, address, phone)
values('111','John','new','123-4567')";
I hope that's correct...
Cheers,
Al,
<stil...@ryuji.net> wrote in message
news:MPG.15d72e127...@news-byoa.prodigy.net...