WAS JDBC를 사용한 오라클 이중화 설정
페이지 정보
작성자 미친새 작성일 21-08-25 12:15 조회 12,864 댓글 0본문
일반적으로 DB 이중화에 따른 설정을 WAS에는 하지 않았는데, 그 이중화 설정을 WAS에서 처리할 일이 생겼다.
일반적인 JDBC 설정
(CommonDBCP2에서는 maxActive -> maxTotal, maxWait -> maxWaitMillis로 변경)
<Resource name="datasource"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@//192.168.x.x:1521/orcl"
username="user"
password="password"
maxTotal="10"
maxIdle="5"
maxWaitMillis ="-1"/>
이중화에 따른 JDBC 설정
아래 설정 부분을 URL 부분에 한줄로 작성
jdbc:oracle:thin @(
DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=dbserv1)(PORT=1521) )
(ADDRESS=(PROTOCOL=TCP)(HOST=dbserv2)(PORT=1521) )
(LOAD_BALANCE=yes)
(FAILOVER=yes)
(CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=DBServiceName)
(FAILOVER_MODE=
(TYPE=SELECT)(METHOD=BASIC)(RETRY=180)(DELAY=5)
)
)
)
)
<Resource name="datasource"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dbserv1)(PORT=1521) ) (ADDRESS=(PROTOCOL=TCP)(HOST=dbserv2)(PORT=1521) ) ... )"
username="user"
password="password"
maxTotal="10"
maxIdle="5"
maxWaitMillis ="-1"/>
Commons DBCP 이해하기 : https://d2.naver.com/helloworld/5102792
#tomcat #jdbc #oracle
출처: https://nakanara.tistory.com/198 [검색의 흐름]
위에꺼 쓰면 에러 난다.
그러면 밑에걸로 괄호 자리수 맞추면 됨.
java.sql.SQLException: IO 예외 상황: NL Exception was generated
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at TestSqlNet.connect(TestSqlNet.java:32)
at TestSqlNet.test(TestSqlNet.java:68)
at TestSqlNet.main(TestSqlNet.java:79)
java.lang.NullPointerException
at TestSqlNet.test(TestSqlNet.java:69)
at TestSqlNet.main(TestSqlNet.java:79)
==> JDBC URL 문법이 잘못 되어 있거나 "(" 또는 ")" 괄호 의 갯수를 확인 해 보도록 한다.
필자의 경우는 "jdbc:oracle:thin:@((DESCRIPTION=" 에서 처럼 DECRIPTION 앞에 시작괄호를 하나 더 넣어서 문제가 되었다.
아래 예제는 올바른 경우다.
String url = "jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=ON)"
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.105)(PORT=1521))"
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=190.168.1.107)(PORT=1521))"
+ "(CONNECT_DATA=(SERVICE_NAME=RACDB)))";
일반적인 JDBC 설정
(CommonDBCP2에서는 maxActive -> maxTotal, maxWait -> maxWaitMillis로 변경)
<Resource name="datasource"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@//192.168.x.x:1521/orcl"
username="user"
password="password"
maxTotal="10"
maxIdle="5"
maxWaitMillis ="-1"/>
이중화에 따른 JDBC 설정
아래 설정 부분을 URL 부분에 한줄로 작성
jdbc:oracle:thin @(
DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=dbserv1)(PORT=1521) )
(ADDRESS=(PROTOCOL=TCP)(HOST=dbserv2)(PORT=1521) )
(LOAD_BALANCE=yes)
(FAILOVER=yes)
(CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=DBServiceName)
(FAILOVER_MODE=
(TYPE=SELECT)(METHOD=BASIC)(RETRY=180)(DELAY=5)
)
)
)
)
<Resource name="datasource"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dbserv1)(PORT=1521) ) (ADDRESS=(PROTOCOL=TCP)(HOST=dbserv2)(PORT=1521) ) ... )"
username="user"
password="password"
maxTotal="10"
maxIdle="5"
maxWaitMillis ="-1"/>
Commons DBCP 이해하기 : https://d2.naver.com/helloworld/5102792
#tomcat #jdbc #oracle
출처: https://nakanara.tistory.com/198 [검색의 흐름]
위에꺼 쓰면 에러 난다.
그러면 밑에걸로 괄호 자리수 맞추면 됨.
java.sql.SQLException: IO 예외 상황: NL Exception was generated
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at TestSqlNet.connect(TestSqlNet.java:32)
at TestSqlNet.test(TestSqlNet.java:68)
at TestSqlNet.main(TestSqlNet.java:79)
java.lang.NullPointerException
at TestSqlNet.test(TestSqlNet.java:69)
at TestSqlNet.main(TestSqlNet.java:79)
==> JDBC URL 문법이 잘못 되어 있거나 "(" 또는 ")" 괄호 의 갯수를 확인 해 보도록 한다.
필자의 경우는 "jdbc:oracle:thin:@((DESCRIPTION=" 에서 처럼 DECRIPTION 앞에 시작괄호를 하나 더 넣어서 문제가 되었다.
아래 예제는 올바른 경우다.
String url = "jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=ON)"
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.105)(PORT=1521))"
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=190.168.1.107)(PORT=1521))"
+ "(CONNECT_DATA=(SERVICE_NAME=RACDB)))";
관련링크
댓글목록 0
등록된 댓글이 없습니다.