C3P0 and JdbcTemplate Configuring Oracle cluster RAC Records

Source: Internet
Author: User
Tags dedicated server

Perac =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 131.197.17.137) (PORT = 1521))
(ADDRESS = (PROTOCOL = TCP) (HOST = 131.197.17.138) (PORT = 1521))
(load_balance = yes)
(FAILOVER = ON)
(Connect_data =
(SERVER = dedicated)
(service_name = PE)
(Failover_mode =
(TYPE = SELECT)
(METHOD = BASIC)
(retries=180)
(delay=5)
)
)
)

It is very simple for me to configure this string connection in the program. Just put this string above the URL tag that previously placed only one URL connection. The previous configuration was just an address. Now there are two, need to use the above string.

Configuration C3p0 no problem, as follows:

<property name= "Connection.url" >jdbc:oracle:thin:@ (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 131.197.17.137) (port = 1521)) (ADDRESS = (PROTOCOL = TCP) (HOST = 131.197.17.138) (port = 1521)) (load_balance = yes) (connect_ DATA = (SERVER = dedicated) (service_name = PE)) </property>



But some operations are done using spring's jdbctemplate. If I want to c3p0 the same two addresses in the URL tag. Will error, as follows:

Connection refused (description= (err=1153) (vsnnum=169870336) (error_stack= (Error= (code=1153) (emfi=4) (ARGS=) ( Address= (PROTOCOL=TCP) (host=131.197.17.138) (port=1521))) (Error= (code=305) (Emfi=1))))



At first I thought it was 138 this machine is not connected, because it is prompted by 138, so I only use 137 of the machine to connect, the result or report this error, finally replaced by 138 to even, put and no problem! But cannot write 137 and 138 at the same time, in fact only use an address. Even when you write an address. Also to write this:

<value>jdbc:oracle:thin:@ (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 131.197.17.138) (PORT = 1521)) (Load_ BALANCE = yes) (Connect_data = (service_name=pe))) </value>

Can not simply url+ Port +sid, or will be error:

Could not get JDBC Connection; Nested exception is Java.sql.SQLException:Io exception: Connection refused (description= (tmp=) (vsnnum=169870336) (err=12505) ( Error_stack= (Error= (code=12505) (emfi=4))))



I'm still trying to configure a dual address in spring's jdbctemplate. Is it because of the org.springframework.jdbc.datasource.DriverManagerDataSource? Want to change to a connection pool? I'll try it! Anyway, the above can be used.



Finally the problem is solved! In fact, the connection string is written directly on the URL tag. Just need your database driver to be up-to-date! This is important. I have a lot of class12.jar, with this driver is very unstable, when good and bad, so change the Ojdbc.jar, boy! How to toss All right! Problem Solving!



The following is reproduced online, stay in the study:

By the way, record the parameters of the configuration link string:

Address is followed by the connected IP and port number nothing to say. Load_balance=yes; Indicates whether the load is balanced. Server = Dedicated; Indicates a dedicated server mode, which can be removed. SERVICE_NAME=ORCL; The service name of the database to manipulate. TYPE = Session indicates that when an instance of a connected session fails, the session is automatically switched to another available instance, and the foreground application does not need to initiate the connection again, but the SQL that the session is executing needs to be re-executed. METHOD = Basic means that the initial connection is connected to a contact, and he has an option of Preconnect, which indicates the initial connection of all the contacts. Retries: Number of retries. Delay: The delayed retry (in seconds).

And if the Oracle server's listener configuration is the machine name of the machine in the cluster, it is best to change the System32\drivers\etc\hosts file under Winnt. Finally add the IP corresponding machine name, for example:

10.37.27.111 LINUX1-VIP

10.37.27.112 LINUX2-VIP

C3P0 and JdbcTemplate Configuring Oracle cluster RAC Records

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.