zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    Hash工具下载地址
    微信聊天记录查看器(程序+源码)
    XEN的启动信息输出到“Platform timer is 14.318MHz HPET”就暂停接收的解决办法
    利用 Serial Over Lan(SOL)搭建 XEN 的调试信息输出环境
    Windows内核开发中如何区分文件对象究竟是文件还是文件夹?
    白盒密码入门
    选择Asp for javascript,非.net。
    8个你至少应该参加一次的极客盛会
    程序员的四种类型
    超棒的30款JS类库和工具
  • 原文地址:https://www.cnblogs.com/freewater/p/2156497.html
Copyright © 2011-2022 走看看