Event: The report interface database suddenly fails to be connected, resulting in the normal count fetch operation. Exception information: Io exception: Got minus one from a read call analysis: the database address and configuration information are changed. After inquiry, the database is changed to the cluster working 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. Thinking width: 1. jdbc jar file selection. What is Classes12? The first time I was dizzy, it was actually the JDBC that came with the oracle database. The whole name was classes12.jar! Common jdbc jar Information
Common JDBC driver package JDK 1.4 JDK 1.5 JDK 1.6 Singleton Database Cluster database Class. forName
1 OracleJdbcDriver9i. jar support not support oracle. jdbc. OracleDriver
2 classes12.jar (oracle 92i) Support support not support oracle. jdbc. OracleDriver
3 ojdbc14.jar (oracle 92i) Support support not support oracle. jdbc. OracleDriver
4 classes12.jar (oracle 10G) Support supports oracle. jdbc. OracleDriver
5. Support for ojdbc14.jar (oracle 10G) Support for oracle. jdbc. OracleDriver
6 ojdbc5.jar not supported without Class. forName Loading
7. ojdbc6.jar is not supported. It is not supported. Class. forName loading is not required.
1: OracleJdbcDriver9i. jar. This is my common JDBC driver! The origin is unknown. The contents of the account book (MANIFEST. MF) are empty. The preliminary analysis is the product of the oracle92i era. Serial number 2, 3: The same outbound portal, all of which come with oracle92i. Home Address: oracle/jdbc/libclasses12.jar account 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.jar account 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: Products of oracle 10G and oracle 92i The biggest difference is that cluster query is supported. 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. If the project supports JDK or later, select Recommendation Number 6 and study the new features.
2. Connect strings in the cluster working mode... Select attributes outside the connection with caution. Lazy 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 retries. append ("(delay = 15)"); // The unit of DELAY retry delay is second url. append (")"); // failover_mode end url. append (")"); // connect_data end url. append (")"); // description ends