OracleDatabase 配置

tnsnames.ora
ORCL=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
10.3.5.78 )(PORT = 1522))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)

  法一:

 1 OracleDataSource ds = new OracleDataSource();
2 ds.setDriverType("oci");
3 ds.setNetworkProtocol("tcp");
4 ds.setServerName("10.3.5.78");
5 ds.setPortNumber(1522);
6 ds.setDatabaseName("orcl");
7 ds.setUser("scott");
8 ds.setPassword("tiger");

  法二:

OracleDataSource ds = new OracleDataSource();
ds.setDriverType(
"oci");
ds.setTNSEntryName(
"orcl");
ds.setUser(
"scott");
ds.setPassword(
"tiger");

  法三:

OracleDataSource ds = new OracleDataSource();
ds.setURL(
"jdbc:oracle:oci:@orcl");
ds.setUser(
"scott");
ds.setPassword(
"tiger");

  If you are using the JDBC Thin or OCI driver, then note the following:

■A URL setting can include settings for user and password, as in the following example, in which case this takes precedence over individual user and password property settings:
jdbc:oracle:thin:scott/tiger@localhost:1521:orcl
■Settings for user and password are required, either directly through the URL setting or through the getConnection call. The user and password settings in a getConnection call take precedence over any property settings.
■If the url property is set, then any tnsEntry, driverType, portNumber, networkProtocol, serverName, and databaseName property settings are
ignored.
■If the tnsEntry property is set, which presumes the url property is not set, then any databaseName, serverName, portNumber, and networkProtocol settings are ignored.
■If you are using an OCI driver, which presumes the driverType property is set to oci, and the networkProtocol is set to ipc, then any other property settings are ignored.
详细参见: Oracle Database JDBC Developer's Guide and References(11.2)  chapter 8.DataSource and URL

转载于:https://www.cnblogs.com/freewater/archive/2011/08/28/2156497.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值