JDBC连接字符串可以指定多个数据库吗

时间:2009-08-11 17:13:19

标签: jdbc

这是我当前的连接字符串:

jdbc:amazon;moduleName=Foobar:oracle:thin:@ab1na-orasvr.db.foobar.com:42111:ab1na

但我需要JDBC才能访问多个数据库。我可以简单地附加第二个模块名称,用分号分隔吗?

2 个答案:

答案 0 :(得分:3)

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST = (ADDRESS =(PROTOCOL=TCP)
(HOST=1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)
(HOST=2)(PORT=1521))(ADDRESS =(PROTOCOL=TCP)
(HOST=3)(PORT=1521))(ADDRESS =(PROTOCOL=TCP)
(HOST=4)(PORT=1521))(ADDRESS =(PROTOCOL=TCP)
(HOST=5)(PORT=1521))(ADDRESS =(PROTOCOL=TCP)
(HOST=6)(PORT=1521))(ADDRESS =(PROTOCOL=TCP)
(HOST=7)(PORT=1521))(ADDRESS =(PROTOCOL=TCP)
(HOST=8)(PORT=1521))(FAILOVER=on) (LOAD_BALANCE=ON)) 
(CONNECT_DATA = (SERVER=DEDICATED) 
(SERVICE_NAME =ccbfsinterface.comp.pge.com)))

答案 1 :(得分:2)

不,我不认为你能做到这一点。您可以通过创建多个持久性单元并根据您为每个单元提供的名称创建实体管理器来实现Hibernate。

http://schuchert.wikispaces.com/JPA+Tutorial+1+-+Persistence+Unit