permaculture playing cards*
The moose likes JDBC and the fly likes jdbc:odbc with DSN less connection for MS Access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc:odbc with DSN less connection for MS Access" Watch "jdbc:odbc with DSN less connection for MS Access" New topic
Author

jdbc:odbc with DSN less connection for MS Access

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi:
does anyone know what's the syntax for jdbc dbc DSN less connection for MS Access.
I have used the registered DSN which the java code connect using
con = DriverManager.getConnection (
"jdbc dbc:<registeredDSNhere>",
username,
password);
I know how to use file DSN on VJ++ or ASP by putting all the DSN info into a file.dsn.
but how do i do a DSN less connection for MS Access?
edmond so
Greenhorn

Joined: May 17, 2001
Posts: 6
the syntax for the jdbc url, using sun's jdbc-odbc bridge, goes like this:
jdbc dbc:<data-source-name>[;attribute-name>=<attribute-value>]*
to make a DSN-less connection to MS Access (or for that matter, any db for which you have a odbc driver), simply omit the data-source-name and specify the driver and database as attribute name-value pairs. for example, to connect to a MS Access db located at c:\db1.mdb, the url would be:
jdbc dbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=C:/Userdata/db1.mdb
to specify userid and password, include them as attributes. note the semicolon right before your attributes string, right after "jdbc dbc:". also, any path you include should use forward slashes "/" instead of backward slashes "\". the easiest way to get the attributes pairs is to set up a file DSN for your db and copy the name-value pairs right from the file.
hope this helps.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi Edmon so:
thank you so much for replying. I really appreciate it.
I tried it with JDK1.1.8; 1.2 and 1.3
It only works under JDK1.3. However I have to use JDK1.1.8, since I am using PersonalJava VM -- this is an application runs on winCE and we need to use java vs. VB......
under JDK1.1.8 the error is:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException()
at sun.jdbc.odbc.JdbcOdbc.standardError()
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect()
at sun.jdbc.odbc.JdbcOdbcConnection.initialize()
at sun.jdbc.odbc.JdbcOdbcDriver.connect()
at java.sql.DriverManager.getConnection()
at java.sql.DriverManager.getConnection()
at ConnectMDB.main()
under JDK1.2.2 the error is:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection()
at java.sql.DriverManager.getConnection()
at ConnectMDB.main()
Irene
edmond so
Greenhorn

Joined: May 17, 2001
Posts: 6
just a thought - how about downloading the latest jdbc package and importing it... i may not know what i'm talking about...
Nilesh Soni
Greenhorn

Joined: May 14, 2001
Posts: 21

i can connect sql server through a .java file. i mean to say if i will write jdbc code in a .java file compile it and run it from dos/command prompt, it connects database very fine but as soon as i use same code in servlet (although it's too a .java file), it gives me exception that data source name not found. the code is as follows. if you can help me i am very thankful to you as i have already spent much time on it. Please
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
}catch (Exception e) {
System.out.println("Error in Initialising Drivers -> "+e) ;
}
try {
con = DriverManager.getConnection("jdbc dbc:;DRIVER=SQL SERVER;SERVER=mysqlserver;DATABASE=mydatabase","sa","") ;
}catch (Exception e) {
System.out.println("Unable to establish connnection with the database : Reason\n" + e.getMessage()) ;
}
try {
s = con.createStatement() ;
}catch (Exception e) {
System.out.println("Unable to create statement : " + e) ;
}

------------------
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
several things you might need to check:
1. what version JDK the servlet engine is using. It has to be JDK1.3
2. Make sure the JDBC driver properties is setup correctly in your servlet engine.
ie. in weblogic, you have to change the settings of jdbc driver properties and jdbc connection pool.
good luck
Nilesh Soni
Greenhorn

Joined: May 14, 2001
Posts: 21
Dear irene,
i am using JDK 1.3 and i am using java web server2.0. can you make the second point more clear in context of java web server. please

------------------
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi:
i am not familiar with Java Web Server ( only played with it for short time), but isnt it just a web server? Does it have servlet engine running on top of it? if not, how can your servlet run?
I am just thinking loud. I suggest you
1. run some servlet without jdbc and see how does it go.
2. if 1. goes well, try to figure out what version JDK the servlet engine is using.
3. There should have some property file (or xml file) used by java web server which controls the behavior of the web server. There should have some entries to setup jdbc driver..... that's where you need to configure to MS SQL server.
sorry, i cant point to you to the exact spot on java web server. But the above should be the right path to track...
good luck
irene
tom_2000
Greenhorn

Joined: Jun 05, 2001
Posts: 7
hi guys and gals.
MSAccess runs from a local DLL, not NETWORKABLE.
I had to register my jdbc driver as an RMI object for the connection to go through from a servlet.
See this link for further details. I'm surprised that with so many Microsoft Access jdbc attempts, people haven't posted an explicit how-to.
http://www.objectweb.org/RmiJdbc/Access/access.html
g'luck
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc:odbc with DSN less connection for MS Access
 
Similar Threads
a simple search app that accesses access?
java interface to DB on winCE
configuring dsn connection automatically
memo field in Access
dynamic creation of Data Source Name(DSN) programatically , help needed urgent