This release of Oracle JVM supports Internet Protocol Version 6 (IPv6) addresses in the URL and system names of the Java code in the database, which resolve to IPv6 addresses.
Database URLs are strings that you specify for the value of the url
property of the DataSource
object. The complete URL syntax is the following:
jdbc:oracle:driver_type:[username/password]@database_specifier
The first part of the URL specifies which JDBC driver is to be used. The supported driver_type
values for client-side applications are thin
and oci
. The brackets indicate that the user name and password pair is optional. The database_specifier
value identifies the database to which the application is connected.
The following is the syntax for thin-style service names that are supported by the Thin driver:
jdbc:oracle:
driver_type
:[
username
/
password
]@//
host_name
:
port_number
:
SID
For the sample application created in this guide, if you include the user name and password, and if the database is hosted locally, then the database connection URL is as shown in Example 3-1.
Example 3-1 Specifying the url Property for the DataSource Object
jdbc:oracle:thin:hr/hr@localhost:1521:oracle
If you have performed Oracle Database server installation in Typical mode, then the default service name used by the Oracle instance is ORCL
, and the following Easy Connect syntax can be used to connect to that instance:
sqlplus /nolog SQL> CONNECT username@"host/ORCL" SQL> Enter password: password
The Easy Connect feature, which was introduced in Oracle Database 11g Release 1 (11.1), makes the following parts of the conventional JDBC connection URL syntax optional:
jdbc:oracle:
driver_type
:[
username/password
]@[//]
host_name
[:
port
][:oracle]
In this URL:
// is optional.
:port
is optional.
Specify a port only if the default Oracle Net listener port (1521) is not used.
:oracle
(or the service name) is optional.
The connection adapter for the Oracle Database connects to the default service on the host. On the host, this is set to ORACLE
in the listener.ora
file.
After making changes to the listener.ora
file, you must restart the listener with the following command:
> lsnrctl start mylistener
The following URLs should work with this configuration:
jdbc:oracle:thin:@//test555.testserver.com jdbc:oracle:thin:@//test555.testserver.com:1521 jdbc:oracle:thin:@test555.testserver.com jdbc:oracle:thin:@test555.testserver.com:1521 jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test555.testserver.com)(PORT=1521))) jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test555.testserver.com))) jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test555.testserver.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=)))
Note:
Default service is a new feature in Oracle Database 12c Release 1 (12.1). If you use any other version of the Oracle Database to connect to the database, then you must specify the SID and port number.
Example 3-2 Default Service Configuration in listener.ora
MYLISTENER = (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=test555)(PORT=1521)) ) DEFAULT_SERVICE_MYLISTENER=dbjf.regress.rdbms.dev.testserver.com SID_LIST_MYLISTENER = (SID_LIST= (SID_DESC=(SID_NAME=dbjf)(GLOBAL_DBNAME=dbjf.regress.rdbms.dev.testserver.com)(ORACLE_HOME=/test/oracle)) )
Related Topics