Does the Sqlplus host string have any importance in jdbc?
Can anyone please tell me whether the host string field that is used 开发者_JAVA技巧when logging in from Sqlplus has any role in jdbc?
This depends on the database specifier used in the JDBC URL. For most purposes, the host string (or more correctly known as the net service name) is not usually not required, for the entries in the tnsnames.ora file is not read when determining the Oracle instance to connect to. Most developers using JDBC, use database URL schemes that do not require this.
The information about the Oracle database service is typically read from the JDBC URL itself, which in the case of Oracle, has the following notation:
jdbc:oracle:<driver_type>:[username/password]@database_specifier
The username and password is optional; there are other means to specify the username and password. The driver utilizes the information specified in the database specifier field to determine the location of the Oracle listener, hence absolving the need to have a separate Oracle home with explicit connect descriptors to locate a database service.
The Oracle Database JDBC Developer's Guide lists all possible database specifiers that can be used. In most scenarios, the thin-style service name syntax is used, where the net service name is not required (and the actual service name of the database would be specified). The only exception is the case where a TNSNames alias
has been specified in the source code, and the location of the tnsnames.ora
file has been specified using the oracle.net.tns_admin
property.
精彩评论