DNS and TNS Names in JDBC | Java JDBC Tutorial

This Java JDBC Tutorial  “DNS and TNS Names” post is providing the information about importance of DNS names in Sun driver loading process and TNS names in Oracle Driver loading process.


 

Setting DSN :

  • Stands for Data Source Name.
  • DSN settings mandatory for JDBC-ODBC-Bridge driver.
  • DSN is an alias name to work with specified ODBC among available.

 

How to set DSN name:

  1. Start
  2. Open Control panel
  3. Select Administrative Tools
  4. Click on Data Sources(ODBC)
  5. Click on SystemDSN tab on the window
  6. Click on Add button.
  7. Choose Microsoft ODBC for Oracle.
  8. Click on Finish
  9. Give DSN name in Data Source Name column.
  10. Click on ok
  11. Now u can work with type1 driver.

 

Data Source Name in JDBC

 

DSN names in JDBC

 

 

Setting TNS:

  • Stands for Transparent Network Substrate.
  • We need to set classpath to work with Oracle driver
  • Set the classpath for below string in system environment variables area.
    C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar ;

Finding TNS name in the System:

  1. Open C:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN.
  2. Open tnsnames.ora file using text editor.
  3. Check the SERVICE_NAME that is your TNS name
Share this