Java query the Oracle Database Cluster connection string and JDBC jar package selection.

Source: Internet
Author: User
Tags dedicated server

 

Java query the Oracle Database Cluster connection string and JDBC jar package selection. event: The report interface database suddenly fails to be connected, resulting in a failure to retrieve data normally. exception information: Io exception: got minus one from a read call

Analysis: the database address and configuration information change. After inquiry, the database is changed to the cluster mode. result: 1. modify the common JDBC connection string to the cluster working mode. 2. the jdbc jar file in the interface is not suitable for cluster operation. 1. jdbc jar file selection,

Serial number Common JDBC driver packages JDK 1.4 JDK 1.5 JDK 1.6 Singleton Database Cluster Database Class. forname
1 Oraclejdbcdriver9i. Jar Supported Supported Supported Supported Not Supported Oracle. JDBC. oracledriver
2 Classes12.jar (Oracle 92i) Supported Supported Supported Supported Not Supported Oracle. JDBC. oracledriver
3 Ojdbc14.jar (Oracle 92i) Supported Supported Supported Supported Not Supported Oracle. JDBC. oracledriver
4 Classes12.jar (Oracle 10g) Supported Supported Supported Supported Supported Oracle. JDBC. oracledriver
5 Ojdbc14.jar (Oracle 10g) Supported Supported Supported Supported Supported Oracle. JDBC. oracledriver
6 Ojdbc5.jar Not Supported Supported Supported Supported Supported Class. forname loading not required
7 Ojdbc6.jar Not Supported Not Supported Supported Supported Supported Class. forname loading not required

1: oraclejdbcdriver9i. Jar. This is my common JDBC driver! The account name (manifest. mf) the content is blank. The preliminary analysis is the product of oracle92i era. serial number 2, 3: The same outbound portal, all of which come with oracle92i, home address: Oracle/jdbc/lib Classes12.jarAccount Description: Specification-title: "oracle JDBC driver classes for use with jdk1.2 and jdk1.3" Specification-version: "oracle JDBC driver version-9.0.2.0.0" Ojdbc14.jarAccount Description: Specification-title: "oracle JDBC driver classes for use with jdk1.4" Specification-version: "oracle JDBC driver version-9.0.2.0.0" No. 4, 5: the biggest difference between the product of Oracle 10g and Oracle 92i is that it supports cluster query. no. 6, 7: ojdbc5.jar supports JDK 1.5, JDBC 3.0 ojdbc6.jar supports JDK 1.6, and JDBC 4.0 does not require Class execution. forname ("oracle. JDBC. oracledriver "); directly
Drivermanager. getconnection (URL, user, PWD); OK. If the project only supports jdk1.4, do not act rashly. Select No. 4 or 5. If the project supports jdk1.5 or a later Recommendation Number of 6, 7 study the new features.
2. Connect strings in the cluster working mode... select attributes outside the connection with caution. Lazy and paste the code!
Stringbuffer url = new stringbuffer (); URL. append ("JDBC: oracle: thin: @ (description = (address_list ="); URL. append ("(address = (Protocol = TCP) (host = 192.168.31.9) (Port = 1521)"); // append cluster information as needed, the format is as follows // BF. append ("(address = (Protocol = TCP) (host = 10.37.27.112) (Port = 1521)"); URL. append ("(load_balance = yes)"); // load_balance = yes; indicates whether the Server Load balancer URL is used. append (")"); // address_list end URL. append ("(CONNECT_DATA ="); URL. append ("(Server = dedicated)"); // server = dedicated; indicates the dedicated server mode. You can remove the URL. append ("(SERVICE_NAME = wangjj)"); // URL of the Database Service name. append ("(failover_mode ="); URL. append ("(type = session)"); // type = session indicates that when the instance of a connected session fails, the system automatically switches the session to another available instance, the front-end application does not need to initiate a connection again, but the SQL statement being executed by the session needs to re-execute the URL. append ("(method = Basic)"); // method = Basic indicates that the initial connection is connected to a contact. The initial connection has a preconnect option, indicating all the contact URLs of the initial connection. append ("(retries = 5)"); // URL of retries. append ("(delay = 15)"); // The unit of delay retry delay is second URL. append (")"); // failover_mode end URL. append (")"); // CONNECT_DATA ends

URL. append (")"); // description ends

Related Article

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.