skip to main content
DataDirect Connect Drivers : Oracle Driver : Using tnsnames.ora Files : Connecting to the Database
  
Connecting to the Database
To retrieve connection information from an Oracle tnsnames.ora file with the Oracle driver, you must inform the driver which tnsnames.ora file (using the TNSNamesFile property) and Oracle service name entry (using the TNSServerName property) to use so that the driver can reference the correct connection information. For example, the following connection URL in a Java string:
jdbc:datadirect:oracle:TNSNamesFile=c:\\oracle\\NETWORK\\
ADMIN\\tnsnames.ora;TNSServerName=FITZGERALD.SALES
specifies the path and file name of the tnsnames.ora file (TNSNamesFile=c:\\oracle\\NETWORK\\ADMIN\\tnsnames.ora) and the net service name entry (TNSServerName=FITZGERALD.SALES) to use for the connection.
Note: The connection URL does not specify the server name and port of the database server; that information is specified in the tnsnames.ora file referenced by the TNSNamesFile property.
Note: If coding a path on Windows to the tnsnames.ora file in a Java string, the backslash character (\) must be preceded by the Java escape character, a backslash. For example: TNSNamesFile=c:\\oracle\\NETWORK\\ ADMIN\\tnsnames.ora
If using tnsnames.ora files with a Security Manager on a Java 2 Platform, read permission must be granted to the tnsnames.ora file. See Granting Access to an Oracle tnsnames.ora File for an example.