wood burning stoves 2.0*
The moose likes JDBC and the fly likes creating   DSN at runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "creating   DSN at runtime" Watch "creating   DSN at runtime" New topic
Author

creating DSN at runtime

Anbanandhan Dhanavelan
Greenhorn

Joined: Jun 12, 2007
Posts: 8
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

Joined: Jun 01, 2007
Posts: 148
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

Joined: Jun 12, 2007
Posts: 8
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

Joined: Apr 14, 2004
Posts: 10336

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)?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Anbanandhan Dhanavelan
Greenhorn

Joined: Jun 12, 2007
Posts: 8
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

Joined: Dec 20, 2006
Posts: 2491
    
    8

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


OCUP UML fundamental and ITIL foundation
youtube channel
Anbanandhan Dhanavelan
Greenhorn

Joined: Jun 12, 2007
Posts: 8
hi jan
thank you for your post;
is there any driver for mac os that support ms access
Thank you
Anbu
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating DSN at runtime
 
Similar Threads
Re-deploying ejb
How to use File DSN in JDBC
JDBC without DSN
creating a DSN
Excel ODBC Data Sources - On the Fly??