freelanceprogrammers.org Forum Index » Java

dsn-less connection


View user's profile Post To page top
c_beginner2001 Posted: Wed Feb 20, 2002 5:00 am


Joined: 31 Jan 2002

Posts: 24
dsn-less connection
Hi everyone, Can anyone tell me how the source
code to create a dsn-less connection to a Microsoft
Access 2000 database called "Test" (using the source
code rather than the control panel to setup the
database).<br><br>So far I have found this code, it compiles but when
I run it I get the following error
message:<br><br>Connection Exception: java.sql.SQLException:
[Microsoft][ODBC Microsoft Access Driver] Could not find file
`(unknown)`.<br><br>Could anyone tell me whats wrong and how to fix it
please.<br><br>-----------------------<br>Code:<br><br>import
java.sql.*;<br><br>public class
MakingTheConnection3 {<br> public static void main(String[] args)
{<br><br>Connection connection;<br> Statement statement;<br> String
url = System.getProperty("user.dir") +
"\catalogo.mdb";<br> String conStr = "jdbc:odbc:Driver={Microsoft
Access Driver (*.mdb)};DBQ=" + url;<br> try{<br>
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");<br> connection =
DriverManager.getConnection(conStr);<br> connection.createStatement();<br> }
catch
(Exception ex){<br> System.out.println("Connection
Exception: " + ex);<br> }<br> }<br>}<br><br>Thanks everyone
Reply with quote
Send private message
View user's profile Post To page top
mcconnell_stephen Posted: Wed Feb 20, 2002 6:00 am


Joined: 01 Feb 2002

Posts: 73
dsn-less connection
What does your url String look like if you do a
System.out.println(url)? Does it look like a path to a valid
file?<br><br>It appears your connect string is OK with finding
the driver, but not able to find the
file...<br><br>I`ve done DNS"less" connections in VB and C++, but not
in Java... for some reason it just didn`t work (lack
of patience in the devloper, probably). You seem to
be on the right track, but just check the value of
your "url".<br><br>Sorry that I couldn`t be of more
help, but I haven`t use MS Access for database in
years.<br><br>Stephen McConnell<br><a href=http://www.crosslogic.com
target=new>http://www.crosslogic.com</a>
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help