Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating DSN at runtime

 
Anbanandhan Dhanavelan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it possible to create DSN at runtime ,
if it is possible could any one give the sample code

Thank you in advance
anbu
 
Bill Cruise
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I search google for DSN I get a lot of different results. Can you elaborate by telling us in more detail what you are trying to do?
 
Anbanandhan Dhanavelan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am having .mdb(MS Access database) file, my clients require an application in cd version, on installing my application the user can use my application as a search engine for this .mdb file.so i decided to develop my application in java, while connecting the access database i use the following method,

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
dbcon=DriverManager.getConnection("jdbcdbc:jobbankdb","user","user");

in this :jobbankdb is a system DSN, this is created in "ODBC Data Source Administrator" in windows "Administrator tools" by manually

i wants to create this DSN(Data Source Name) on runtime
could you please give me sample code so that i can give my application in cd


Thank you
Anbu
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DNS is Windows specific stuff, so you'll need to call some native code. Its easy enough to do in VB (have a hunt through MSDN, you'll fine examples), so you might be better distributing a .wsf with your app that does it (or just documenting that it is a required step in set up)?
 
Anbanandhan Dhanavelan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This appication has to be work in mac os x too,
if i do my application in java swings, i will make it work in both platforms by having small changes in code.

note: actually my database has only one table with 40 columns and about lacks of records
any idea

Thank you
Anbu
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't want to create an odbc source in Windows, you can providse all settings at runtime, like in this example:

(solution from http://www.techbookreport.com/tutorials/jdbcodbc.html)

If you want to make it work on Win and Mac, you might want to look for a proper jdbc driver for your database, and step away from the jdbc-odbc bridge.
You will not regret it.

Regards, Jan
 
Anbanandhan Dhanavelan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi jan
thank you for your post;
is there any driver for mac os that support ms access
Thank you
Anbu
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,
There are both jdbc and odbc drivers available for Access that work on a Mac.
Search the web for "os x" access jdbc driver and "os x" access odbc driver. I do not know if there is a driver available for free.
Regards, Jan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic