• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jdbc:odbc with DSN less connection for MS Access

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just a thought - how about downloading the latest jdbc package and importing it... i may not know what i'm talking about...
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic