| Author |
Dynamic DSN creation
|
abhinav singhal
Greenhorn
Joined: Jun 19, 2003
Posts: 29
|
|
Hi All, I want to Dynamically generate the DSN for database connectivity, so that i do not need to go to ODBC and create DSN for the database. Is there any way by which we can create the DSN for a particular database in our code itself and then use it for querrying. Thanks! Abhinav
|
 |
Julian Kennedy
Ranch Hand
Joined: Aug 02, 2004
Posts: 823
|
|
The DSN for a Windows ODBC connection is held in the registry. You can export a specific DSN into a .reg file which you can then reload into the registry. It's possible that you could use a variation of that technique to create the DSN. Of course your code would have to have permission to run on each relevant machine. Another alternative may be to use an API to register the DSN in the registry. Hope this helps. Jules
|
 |
Afroz Ahmed
Ranch Hand
Joined: Jan 18, 2004
Posts: 64
|
|
Hai, You can use system dsn,so that any user of the system can use it.Else,create file dsn and you are not needed to create every time,just set the location of the file dsn. Dsn file basically contains the location of the driver name,location,datasource name,username etc. If you do not want dsn to be used,go for type 2 or type 4 Driver.There will be no need to craete dsn. Here is the sample for them Type 2 - The Oracle OCI JDBC driver requires an installation of Oracle's SQL*Net to provide communication to the database server. Class.forName ("oracle.jdbc.driver.OracleDriver"); Connection conn = DriverManager.getConnection ("jdbc : oracle : oci8 : @hostname : Databasename", "scott", "tiger"); Type 4 - 100% Java Driver mainly used for webappl.Fast access.Nothing is needed preinstalled. Oracle provides thin driver for this. Driver driver = (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); DriverManager.registerDriver(driver); conn = DriverManager.getConnection("jdbc : oracle : thin : @127.0.0.1:1521 bname", "scott", "tiger")  [ August 05, 2004: Message edited by: Mohd Afroz Ahmed ]
|
The value of an idea lies in the usage of it.
|
 |
 |
|
|
subject: Dynamic DSN creation
|
|
|