18 June 2009

Weblogic Server DataSource Using TNS Names

As of Oracle JDBC 10.2, it's possible to establish a connection with the thin driver using tnsnames.


This allows you to store your database server details in an external tnsnames.ora file, which you then reference from the JDBC connection URL.

To use this with a Weblogic Server DataSource, try the following:

  1. Create a tnsnames.ora file with the required connection details and store it in a file that is accessible to the WLS instance:
    TEST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = testserver)(PORT = 1521))
    (SERVICE_NAME = test.au.oracle.com)

  2. Edit the setDomainEnv script for your domain and add the following System property

  3. Create a DataSource and specify the connection URL to use the TNS names entry:

When the connection pool needs to create connections, it will lookup and use the specified TNS names entry from tnsnames.ora file in the directory specified oracle.net.tns_admin property.

1 comment:

icyjamie said...

We've tried this, but when we specify a target (server), we still get an error, saying you have to provide a host.