JDBC Connection database uses SID and Service_Name differences ___ Database

Source: Internet
Author: User
Recently used JDBC Connection Oracle times Error:
ORA-12505, Tns:listener does not currently know of SID given into connect descriptor the Connection descriptor used by the C Lient was:

Landing Oracle Data discovery is configured in the Tnsnames.ora under the network/admin/folder: Service_Name =xxxx. The query found that the connection string in JDBC is not used correctly. Java JDBC Thin Driver has three ways to connect to Oracle, as follows:

Format one: Oracle JDBC Thin using a ServiceName:
Notice the format here, @ there's//, this is the main difference from using SIDS.
This format is a recommended format for Oracle because each node's SID is different for a cluster, but service_name can contain all nodes.

Format two: Oracle JDBC Thin using an SID:
Support for SID are being phased out. Oracle recommends that users switch over to Usingservice names.

Format III: Oracle JDBC Thin using a tnsname:
Example:jdbc:oracle:thin: @GL
Support for TNSNames is added in the driver release

Linux Query Sid method:
You can use the Echo $ORACLE _SID when configuring Oracle environment variables, if you do not have the PS-EF |grep Oracle to query:
Oracle 2548 1 0 Aug17? 00:00:00 ora_pmon_xxxx
The following xxxx is the corresponding SID.

In the Windows environment, Oracle is managed in the form of a background service, so see "Control Panel-> management tools-> Services inside the name:" ORACLESERVICEORCL, then ORCL is SID;

The difference between service_name and SID:
SERVICE_NAME: This parameter was introduced by Oracle8i. Before 8i, a SID was used to represent an instance of the identity database, but in Oracle's parallel environment, a database corresponded to multiple instances, requiring multiple network service names and cumbersome settings. To facilitate settings in a parallel environment, the SERVICE_NAME parameter is introduced, which corresponds to a database rather than an instance, and has many other benefits. The default value for this parameter is db_name. Db_domain is equal to Global_name. A database can correspond to multiple service_name in order to achieve a more flexible configuration. This parameter is not directly related to the SID, which means that the service name must be the same as the SID

The SID is the name of the database instance, and each instance is different.

Turn from: http://java-xp.iteye.com/blog/1639607

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.