JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » JDBC/SQL討論區 » Oracle  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
話題被移動
該話題已被移動 - browser , 2003-06-16 17:22
如果您尚不清楚該話題被移動的原因,請參考論壇規則以及本版公告或者聯系本版版主。
本主題所含的標籤
無標籤
作者 連接ORACLE的方式 [精華]
doffboll



發文: 0
積分: 0
於 2003-06-03 11:07 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
各位大大~~
可否提供給我這新手
JSP連接ORACLE的方式與語法阿~~
還有相關的設定等等
感謝感謝~~~~Cool


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
browser

戀香

版主

發文: 3570
積分: 1
於 2003-06-03 11:17 user profilesend a private message to usersend email to browserreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@XXX.XXX.XXX.XXX:1521:SID","USER", "PASSWORD");
    
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

其中
XXX.XXX.XXX.XXX 是Oracle DB的ip位置
1521 是Oracle DB的port
SID 是Oracle DB的SID

其它應該就不用多說了
這個我測試過
確定可以用

PS.記得下載jdbc driver for oracle,並且安裝好它們
PS.每個oracle的版本都有差異

good luck


browser edited on 2003-06-12 10:20
reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:browser]
doffboll



發文: 0
積分: 0
於 2003-06-03 11:22 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
那請問我要去哪下載JDBC DRIVER FOR ORACLE呢?
還有要怎麼設定呢?
我有將classes12.jsp的路徑寫到classpath了
是這樣嗎?
感謝感謝


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
browser

戀香

版主

發文: 3570
積分: 1
於 2003-06-03 11:31 user profilesend a private message to usersend email to browserreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
doffboll wrote:
那請問我要去哪下載JDBC DRIVER FOR ORACLE呢?

Oracle官方網站

還有要怎麼設定呢?
我有將classes12.jsp的路徑寫到classpath了
是這樣嗎?

這樣子也可以 ... 不然可以放在JSP container專門放置lib的地方
每個JSP container位置都不一樣
good luck

感謝感謝


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
doffboll



發文: 0
積分: 0
於 2003-06-03 11:48 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
<%@page import = "java.sql.*,java.math.*;"%>
<%
DriverManager.registerDriver(new oracle.jdbc.OracleDrive());
%>
只有寫這樣的程式碼
還是有以下的錯誤訊息
Class oracle.jdbc.OracleDrive not found
驅動程式沒裝好~~
試了老半天了~~~~
器死了~~~下載了
ojdbc14也在CLASSPATH裡設定好路徑了..
還是找不到~~
是我下載錯了嗎?
感謝感謝~~~


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
browser

戀香

版主

發文: 3570
積分: 1
於 2003-06-03 12:35 user profilesend a private message to usersend email to browserreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
先說清楚你的執行環境
應該就能解決你的問題
在什麼平台,jdk版本,什麼container ...


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
hambking





發文: 39
積分: 2
於 2003-06-03 12:55 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
ㄟ..如果是在Window下面的話....

最快速的方法就把它放到
jdk目錄/jre/lib/ext這個目錄下面.....

他就會找的到囉....不過......最好不要什麼東西都塞在那邊比較好...

呵呵...


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
doffboll



發文: 0
積分: 0
於 2003-06-03 12:57 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
謝謝你
我是試試看


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
doffboll



發文: 0
積分: 0
於 2003-06-03 13:09 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我用W2000
裝resin-2.1
jdk1.4.0
這些
謝謝~~~
我朋友有連上
但是他是誤打誤撞的...
所以問他怎麼連的他也不知道
所以囉~~~
請幫忙教我~~
因為以後單機測試OK要換到SERVER上
謝謝


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
doffboll



發文: 0
積分: 0
於 2003-06-03 13:12 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
ORACLE的版本~~~
Oracle8 Enterprise Edition Release 8.0.3.0.0 版,
我好像都是用9i的喔....
哇勒~~~


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
browser

戀香

版主

發文: 3570
積分: 1
於 2003-06-03 13:17 user profilesend a private message to usersend email to browserreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
doffboll wrote:
我用W2000
裝resin-2.1
jdk1.4.0
這些
謝謝~~~
我朋友有連上
但是他是誤打誤撞的...
所以問他怎麼連的他也不知道
所以囉~~~
請幫忙教我~~
因為以後單機測試OK要換到SERVER上
謝謝


以我電腦上的平台 win 2000 sp2 + resin 2.1.9 而言
把抓到合適的driver放至C:\resin-2.1.9\lib (if resin install c:\)
這樣子應該就抓的到你的driver
good luck


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
doffboll



發文: 0
積分: 0
於 2003-06-03 13:54 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
所謂的合適....
你能提供給我嗎?
還有相關的設定...
我已將江我所有抓到的DRIVE都放到
C:\resin-2.1.0\lib
結果....還是找不到ㄋ~~~
拜託拜託~~~


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
browser

戀香

版主

發文: 3570
積分: 1
於 2003-06-03 14:04 user profilesend a private message to usersend email to browserreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
doffboll wrote:
所謂的合適....
你能提供給我嗎?
還有相關的設定...
我已將江我所有抓到的DRIVE都放到
C:\resin-2.1.0\lib
結果....還是找不到ㄋ~~~
拜託拜託~~~


要重開resin ...


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
doffboll



發文: 0
積分: 0
於 2003-06-03 14:33 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
感謝.....
成功了啦~~~
哈哈哈
謝謝你喔
~~~~~


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:browser]
Sei

讓我養隻狗狗吧



發文: 22
積分: 0
於 2003-06-16 17:18 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
去oracle網站(OTN)下載ORACLE專用的DRIVER,四個(oracle_classes12.zip、oracle_jdbc901jdk13x_jdk12x-sol.zip、oracle_nls_charset12.zip、oracle_ocrs12.zip),直接丟到Resin的lib裡
以下是import的寫法
import="java.sql.*,oracle.jdbc.*,oracle.jdbc.*,oracle.jdbc.pool.*"
ORACLE連接的寫法
String oracleURL = "jdbc:oracle:thin:@XXX.XXX.XXX.XXX:1521:SID";
String oracleUsername = "您的使用者名稱";
String oraclePassword = "您的密碼";
OraclePooledConnection oracle_Temp = new OraclePooledConnection(oracleURL,oracleUsername,oraclePassword);

補一下Oracle9i JDBC Programming書裡一段Connection Pooling with the Thin Driver
import javax.sql.*;
import oracle.jdbc.pool.*;

OracleConnectionPoolDataSource myODPDS=new OracleConnectionPoolDataSource();
myOCPDS.setServerName("localhost");
myOCPDS.setDatabaseName("ORCL");
myOCPDS.setPortNumber(1521);
myOCPDS.setDriverType("thin");
myOCPDS.setUser("USER_NAME");
myOCPDS.setPassword("USER_PASSWORD");
PooledConnection myPooledConnection=myOCPDS.getPooledConnection("USER_NAME","USER_PASSWORD");
Connection myConnection=myPooledConnection.getConnection();
...
myConnection.close();


Sei edited on 2004-05-05 15:01
reply to postreply to post
我的思想漫步在寂靜森林裡
揚起空氣般透明的翅膀
跳出自由的第一支舞
作者 Re:連接ORACLE的方式 [Re:doffboll]
mmwy





發文: 4
積分: 0
於 2004-05-05 00:38 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
??代??:D:\oracle\ora817\jdbc\demo\demo.zip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.sql.*;
import javax.sql.*;
import oracle.jdbc.driver.*;
import oracle.jdbc.pool.*;
 
class CCache1
{
  public static void main (String args [])
       throws SQLException
  {
    OracleConnectionCacheImpl ods = new OracleConnectionCacheImpl();
    String url = "jdbc:oracle:oci8:@";
    try {
      String url1 = System.getProperty("JDBC_URL");
      if (url1 != null)
        url = url1;
    } catch (Exception e) {
      // If there is any security exception, ignore it
      // and use the default
    }
 
    ods.setURL(url);
    ods.setUser("scott");
    ods.setPassword("tiger");
 
     // Set the Max Limit
    ods.setMaxLimit (3);
 
    Connection conn1 = null;
    conn1 = ods.getConnection();


browser edited on 2004-05-05 00:41
reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
javalien





發文: 60
積分: 0
於 2004-07-06 23:36 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
各位前輩們大家好丫…我也是個新手…
想請問一下大家,如果我用的是oracle9i的話…
要如何設定它的Classpath呢?
還有,我在oracle的資料夾?奡N已經有jdbc的driver了呢!
我是在winxp寫一個java的程式,使用的資料庫是oracle9.2.0.1的…
這樣子可以嗎?
請各位前輩們幫我解答一下,謝謝!!^^


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:javalien]
darkside





發文: 44
積分: 3
於 2004-07-07 10:25 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
javalien wrote:
想請問一下大家,如果我用的是oracle9i的話…
要如何設定它的Classpath呢?


c:\oracle\ora92\jdbc\lib\ojdbc14.jar

連線的 URL:
1
jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:your_db_sid


xxx 是 Oracle server 的 IP address
your_db_sid 是你的資料庫的 SID。


darkside edited on 2004-07-07 10:47
reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:darkside]
javalien





發文: 60
積分: 0
於 2004-07-07 13:32 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
darkside wrote:
c:\oracle\ora92\jdbc\lib\ojdbc14.jar

連線的 URL:
1
jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:your_db_sid


xxx 是 Oracle server 的 IP address
your_db_sid 是你的資料庫的 SID。


可是…不好意思哦...
我將環境變數 path 跟 class path 都設好了…
但是它還是出現...

1
2
3
4
5
6
7
8
9
10
11
Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClassInternal(Unknown Source)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Unknown Source)
  at Thin_test.main(Thin_test.java:18)
以上的錯誤訊息....
是不是缺少了什麼東西?還是說要解壓縮些什麼東西呢?
小女子才剛學這個東西…還是說有什麼可以參考的書籍呢?
請各位前輩指導一下…謝謝!^^


anthonychen edited on 2004-07-07 14:15
reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
gfortune





發文: 28
積分: 0
於 2004-07-07 21:55 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
oracle.jdbc.driver.OracleDriver

i這個是thin driver ,所需要的jar檔為
classes12.jar 不是 ojdbc14.jar

換一下吧!


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:gfortune]
javalien





發文: 60
積分: 0
於 2004-07-08 12:05 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
gfortune wrote:
oracle.jdbc.driver.OracleDriver

i這個是thin driver ,所需要的jar檔為
classes12.jar 不是 ojdbc14.jar

換一下吧!

不好意思耶!感覺還是不行…
它還是會出現那個怪怪的訊息....


reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:browser]
una0120





發文: 4
積分: 0
於 2004-08-19 00:11 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
browser wrote:
以我電腦上的平台 win 2000 sp2 + resin 2.1.9 而言
把抓到合適的driver放至C:\resin-2.1.9\lib (if resin install c:\)
這樣子應該就抓的到你的driver
good luck


una0120 edited on 2004-09-27 00:47
reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:javalien]
fengmingk





發文: 9
積分: 0
於 2004-10-14 17:04 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我聯Oracle也遇到同樣的狀況,試了好久!(Tomcat 5.0.28+Oracle)
最後在jakata JNDI Resources HOW-TO網頁上http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html看到一段:

Firstly by default, Tomcat will only use *.jar files installed in $CATALINA_HOME/common/lib therefore classes111.zip or classes12.zip will need to be renamed with a .jar extension. Since jarfiles are zipfiles, there is no need to unzip and jar these files - a simple rename will suffice. Also, you should be aware that some (early) versions of Tomcat 4.0 when used with JDK 1.4 will not load classes12.zip unless you unzip the file, remove the javax.sql.* class heirarchy and rejar.

丟到JAVA-HOME/JRE/lib/ext下好像不是好辦法,把classes12.zip直接改名為classes12.jar再丟到{Tomcat}\webapps\..\WEB-INF\lib就ok了,也沒有設定CLASSPATH!
要砍掉JAVA-HOME/JRE/lib/ext/classes12.zip記的要先stop Tomcat,放好classes12.jar後也記得要restart Tomcat


fengmingk edited on 2004-10-15 10:19
reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
deanfreeman





發文: 2
積分: 0
於 2005-02-17 16:46 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
如果你有装oracle的话,它的驱动在%oracle_home%\product\10.1.0\Db_2\jdbc\lib这个目录下,加入classpath就可以了。

reply to postreply to post
作者 Re:連接ORACLE的方式 [Re:doffboll]
weareyang





發文: 6
積分: 0
於 2005-06-15 10:48 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的配置方法可以连接:
c:\j2sdk1.4.1_03;
c:\tomcat 5.0;
c:\JCreatorV3;
将Oracle 8i/jdbc中的classes12.zip拷到c:\j2sdk1.4.1_03\jre\lib\ext,并把名称改为classes12.jar;
设置了tomcat的classpath;
在环境变量中设置了tomcat_home,java_home变量,并在其中增加了值(值为你的classes12.zip的拷贝路径)。


reply to postreply to post
go to first page go to previous page  1   2  go to next page go to last page
» JWorld@TW »  JDBC/SQL討論區 » Oracle

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8