免费看欧美黑人毛片-免费看毛片网站-免费看毛片的网站-免费看久久-中文字幕日韩欧美-中文字幕日韩精品一区

您現在的位置:首頁 > IT認證 > oracle認證 >

oracle的oci和thin區別


我是今天看到tomcat數據源的配置時,想起來這個問題,剛開始還不曉得thin是什么東西!

  database.url=jdbc:oracle:thin:angel/oracle@192.168.55.11:1530:monitordb

  經過上網查詢,得到如下結果:

  jdbc:oracle連接的是oracle數據庫

  thin是一種方法

  angel/oracle那個angel是用戶名,oracle是密碼

  192.168.55.11是你要連的電腦ip

  1530是oracle的連端口(1521貌似是默認端口)

  monitordb這是數據庫的名字

  下面是我轉載的文章,是關于tomcat數據源中oracle的oci和thin區別:

  前幾天同事跑過來跟我說, 機房中的一臺tomcat服務器跟oracle數據庫機連接很慢,查看控制臺中的hibernate日志, 基本上是一條sql出來要等個1-2秒再出第二條。但同樣的程序在他自己機器上的tomcat運行,同樣是連那臺數據庫機器,就快很多,不會出現前面的每執行1條sql就卡一次殼的情況。

  初步分析,我就想到可能是網絡原因, 機房兩臺機器連接不暢通, 程序和機器差的原因基本可以排除, 機房的tomcat機比我們開發機要強多了, 而且程序在他的機器上運行又沒有問題。于是我就勸他到機房去檢查一下網絡狀態, 但他一時也無法進入,因為機房的管理人員不在。

  過了一會, 他告訴我問題解決了, 把數據庫訪問的url更換成了oci方式就好了, oci對我來說有些陌生, 我一直是用的thin,也沒想過其他連接方式。對于oci我也只能想到oracle 的client中貌似是有oci什么的,當時有其他事情也沒管了。

  今天有意了解一下區別,先看看thin和oci的url寫法上的區別:jdbc:oracle:thin:@server ip: service jdbc:oracle:oci:@service看來oci的還更加簡潔,ip可以省掉不寫了。

  接下來再找找oci和thin的其他區別,發現有如下解釋:引用

  Oracle provides four different types of JDBC drivers, for use in different deployment scenarios. The 10.1.0 drivers can access Oracle 8.1.7 and higher. While all Oracle JDBC drivers are similar, some features apply only to JDBC OCI drivers and some apply only to the JDBC Thin driver.

  JDBC OCI client-side driver: This is a JDBC Type 2 driver that uses Java native methods to call entrypoints in an underlying C library. That C library, called OCI (Oracle Call Interface), interacts with an Oracle database. The JDBC OCI driver requires an Oracle client installation of the same version as the driver.

  The use of native methods makes the JDBC OCI driver platform specific. Oracle supports Solaris, Windows, and many other platforms. This means that the Oracle JDBC OCI driver is not appropriate for Java applets, because it depends on a C library.

  Starting from 10.1.0, the JDBC OCI driver is available for install with the OCI Instant Client feature, which does not require a complete Oracle client-installation. Please refer to Oracle Call Interface for more information.

  JDBC Thin client-side driver: This is a JDBC Type 4 driver that uses Java to connect directly to Oracle. It implements Oracle's SQL*Net Net8 and TTC adapters using its own TCP/IP based Java socket implementation. The JDBC Thin driver does not require Oracle client software to be installed, but does require the server to be configured with a TCP/IP listener.

  Because it is written entirely in Java, this driver is platform-independent. The JDBC Thin driver can be downloaded into any browser as part of a Java application. (Note that if running in a client browser, that browser must allow the applet to open a Java socket connection back to the server.)

  JDBC Thin server-side driver: This is another JDBC Type 4 driver that uses Java to connect directly to Oracle. This driver is used internally within the Oracle database. This driver offers the same functionality as the client-side JDBC Thin driver (above), but runs inside an Oracle database and is used to access remote databases.

  Because it is written entirely in Java, this driver is platform-independent. There is no difference in your code between using the Thin driver from a client application or from inside a server.

  連接方式有以下幾種:

  Oralce provides four types of JDBC driver.

  Thin Driver, a 100% Java driver for client-side use without an Oracle installation, particularly with applets. The Thin driver type is thin. To connect user scott with password tiger to a database with SID (system identifier) orcl through port 1521 of host myhost, using the Thin driver, you would write :Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@myhost:1521:orcl", "scott", "tiger");

  OCI Driver for client-side use with an Oracle client installation. The OCI driver type is oci. To connect user scott with password tiger to a database with SID (system identifier) orcl through port 1521 of host myhost, using the OCI driver, you would write :Connection conn = DriverManager.getConnection("jdbc:oracle:oci:@myhost:1521:orcl", "scott", "tiger");

  Note that you can also specify the database by a TNSNAMES entry. You can find the available TNSNAMES entries listed in the file tnsnames.ora on the client computer from which you are connecting. For example, if you want to connect to the database on host myhost as user scott with password tiger that has a TNSNAMES entry of MyHostString, enter:Connection conn = DriverManager.getConnection("jdbc:oracle:oci8:@MyHostString","scott","tiger");

  If your JDBC client and Oracle server are running on the same machine, the OCI driver can use IPC (InterProcess Communication) to connect to the database instead of a network connection. An IPC connection is much faster than a network connection. Connection conn = DriverManager.getConnection("jdbc:oracle:oci8:@","scott","tiger");

  Server-Side Thin Driver, which is functionally the same as the client-side Thin driver, but is for code that runs inside an Oracle server and needs to access a remote server, including middle-tier scenarios. The Server-Side Thin driver type is thin and there is no difference in your code between using the Thin driver from a client application or from inside a server. Server-Side Internal Driver for code that runs inside the target server, that is, inside the Oracle server that it must access. The Server-Side Internal driver type is kprb and it actually runs within a default session. You are already "connected". Therefore the connection should never be closed. To access the default connection, write:DriverManager.getConnection("jdbc:oracle:kprb:");or:DriverManager.getConnection("jdbc:default:connection:");

  You can also use the Oracle-specific defaultConnection() method of the OracleDriver class which is generally recommended:OracleDriver ora = new OracleDriver();Connection conn = ora.defaultConnection();

  Note: You are no longer required to register the OracleDriver class for connecting with the Server-Side Internal driver, although there is no harm in doing so. This is true whether you are using getConnection() or defaultConnection() to make the connection. Any user name or password you include in the URL string is ignored in connecting to the server default connection. The DriverManager.getConnection() method returns a new Java Connection object every time you call it. Note that although the method is not creating a new physical connection (only a single implicit connection is used), it is returning a new object. Again, when JDBC code is running inside the target server, the connection is an implicit data channel, not an explicit connection instance as from a client. It should never be closed.

  這下基本明白了1)從使用上來說,oci必須在客戶機上安裝oracle客戶端或才能連接,而thin就不需要,因此從使用上來講thin還是更加方便,這也是thin比較常見的原因。

  2)原理上來看,thin是純java實現tcp/ip的c/s通訊;而oci方式,客戶端通過native java method調用c library訪問服務端,而這個c library就是oci(oracle called interface),因此這個oci總是需要隨著oracle客戶端安裝(從oracle10.1.0開始,單獨提供OCI Instant Client,不用再完整的安裝client)

  3)它們分別是不同的驅動類別,oci是二類驅動, thin是四類驅動,但它們在功能上并無差異。

  4)雖然很多人說oci的速度快于thin,但找了半天沒有找到相關的測試報告。

相關文章

無相關信息
更新時間2022-03-13 11:05:03【至頂部↑】
聯系我們 | 郵件: | 客服熱線電話:4008816886(QQ同號) | 

付款方式留言簿投訴中心網站糾錯二維碼手機版

客服電話:




主站蜘蛛池模板: 下载抖音| 《非常案件》电视剧| 金珠韩国电影| 林祖辉| 1988版14集电视剧平凡的世界| 漂亮孕妇突然肚子疼视频 | 李采潭和闵度允| 李子京| 5.25心理健康日主题班会ppt| 触底反弹电影| 在线观看高清电影| 蛋仔图片100张| jenna haze| 被抛弃的青春1982| 向团组织靠拢的打算| 刘亦菲mv| 我的父亲是板凳 电视剧| 李志毅| 八年级上册英语课堂作业答案| tina kay| junk boy| 大地免费在线观看| 妻子的电影| 送老师锦旗写什么最好| 尹雪喜新建文件夹2| 在灿烂的阳光下简谱| 寇世勋个人资料简介| 女村长| 高照清雅| 少女模特电影| 孕期体重增长参照表| 我和我的| 一人之下动画| 黄视频免费在线播放| 电影不知不觉诱惑你| 老司机免费看视频| 厕所英雄| 肖传国| 《流感》高清在线观看| 日本电影怪物| 网上视频|