Using the Server-Side Thin Driver
With the server-side Thin driver you now have two ways to connect to another Oracle database from a Java program in an Oracle database. You can create a database link or use the server-side Thin driver. In my opinion, it’s a much better solution to use database links than to use the server-side Thin driver. With database links you get the following advantages:
Transparent distributed transaction management
Centralized administration of the database connection
Centralized database security
To access another database with the Thin driver, you need to use:
An
XAConnection
for distributed transaction managementAn appropriate database URL in each Java object
However, you also open the database to security compromises. For
example, to access an Oracle database outside of the current
database, you need to set up a SocketPermission
security policy to allow your Java program to open a socket to the
external database. Once that policy is created, any program can use
it to open external connections. This also means that external
programs can access the current database without going through its
authentication system. That said, there may be times when an external
connection using the Thin driver is the right solution to a problem.
So let’s examine the use of the Thin driver by working through
an example.
A Server-Side Thin Driver Example
Example 5-4 contains a stored procedure that makes a connection to an external database using the Thin driver. This stored procedure, ...
Get Java Programming with Oracle JDBC now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.