日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

低版本jdbc连接高版本oracle,转:oracle11g的JDBC连接 URL和之前的版本有一定的区别...

發(fā)布時(shí)間:2023/11/27 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 低版本jdbc连接高版本oracle,转:oracle11g的JDBC连接 URL和之前的版本有一定的区别... 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

今天安裝了oracle11g后,寫(xiě)了JDBC測(cè)試程序,一直都連接不上!

一直找不到原因

后來(lái)讀了一下安裝文件中的Readme.txt文檔,汗啊!這個(gè)版本居然把url的訪問(wèn)方式改變了:

Some Useful Hints In Using the JDBC Drivers

-------------------------------------------

Please refer to "JDBC Developer's Guide and Reference" for

details

regarding usage of Oracle's JDBC Drivers.?This

section only offers

useful hints.?These hints are not meant to be

exhaustive.

These are a few simple things that you should do in your JDBC

program:

1. Import the necessary JDBC classes in your

programs that use JDBC.

For

example:

import java.sql.*;

import java.math.*; // if needed

To use

OracleDataSource, you need to do:

import oracle.jdbc.pool.OracleDataSource;

2. Create an OracleDataSource instance.

OracleDataSource ods = new OracleDataSource();

3. set the desired properties if you don't

want to use the

default

properties. Different connection URLs should be

used for

different JDBC drivers.

ods.setUser("my_user");

ods.setPassword("my_password");

For the

JDBC OCI Driver:

To make a bequeath connection, set URL as:

ods.setURL("jdbc:oracle:oci:@");

To make a remote connection, set URL as:

ods.setURL("jdbc:oracle:oci:@");

where is either a

TNSEntryName

or a SQL*net name-value pair defined in tnsnames.ora.

For the JDBC

Thin Driver, or Server-side Thin Driver:

ods.setURL("jdbc:oracle:thin:@");

where is either a string

of the form

//:/,

or a SQL*net name-value pair,

or a TNSEntryName.

For the

JDBC Server-side Internal Driver:

ods.setURL("jdbc:oracle:kprb:");

Note that the trailing ':' is necessary. When you use the

Server-side Internal Driver, you always connect to the

database you are executing in. You can also do this:

Connection conn =

new oracle.jdbc.OracleDriver().defaultConnection();

4. Open a connection to the database with

getConnection()

methods

defined in OracleDataSource class.

Connection conn = ods.getConnection();

------------------------------------------------------------------------

還是得好好看原始文檔啊!

但是還是不明白,為什么突然要改變呢?

總結(jié)

以上是生活随笔為你收集整理的低版本jdbc连接高版本oracle,转:oracle11g的JDBC连接 URL和之前的版本有一定的区别...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

歡迎分享!

轉(zhuǎn)載請(qǐng)說(shuō)明來(lái)源于"生活随笔",并保留原作者的名字。

本文地址:低版本jdbc连接高版本oracle,转:oracle11g