在JBuilder中須如何得其JNDI

Java 技術論壇
註冊 | 登入 | 幫助 | 全文檢索 | 排行榜 | 文章統計  

<script language=javascript> function copyText(obj) { var rng = document.body.createTextRange(); rng.moveToElementText(obj); rng.scrollIntoView(); rng.select(); rng.execCommand("Copy"); rng.collapse(false); } </script>
» Java 技術論壇 » Java IDE » JBuilder  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to topicflat modethreaded modego to previous topicgo to next topic
作者請問如何在JBuilder中使用TomCat中設定的DataSource [精華]
stallone_hwang





發文: 9
積分: 0
於 2003-11-27 16:47 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在%CATALINA_HOME%/conf/server.xml中設定的DataSource(參考TomCat Document)
但在JBuilder中須如何得其JNDI??


Context ctx = new InitialContext();

DataSource ds =
(DataSource)ctx.lookup(
"java:comp/env/jdbc/TestDB");

作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
browser

戀香

總版主

發文: 2598
積分: 2
於 2003-11-27 18:53 user profilesend a private message to usersend email to browserreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
stallone_hwang wrote:
在%CATALINA_HOME%/conf/server.xml中設定的DataSource(參考TomCat Document)
但在JBuilder中須如何得其JNDI??


Context ctx = new InitialContext();

DataSource ds =
(DataSource)ctx.lookup(
"java:comp/env/jdbc/TestDB");




不是很了解你所謂 在JBuilder中取得JNDI
不過你附上的程式 ... 的確是取得在 Tomcat 所設定的 JNDI DataSource

新人發言時,請遵照 論壇提問的智慧,並且先閱讀本站常見的 FAQ,謝謝大家合作,共同維護論壇的品質
作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
stallone_hwang





發文: 9
積分: 0
於 2003-11-28 13:52 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
但此程式卻無法取得DataSource.....在JBuilder project中,請問在JBuilder中是應如何設定(JNDI/DataSource)?

ps.須把程式置於Tomcat webapp中才能跑,這樣的話JBuilder就無法發揮作用
作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
fingerNail





發文: 3
積分: 0
於 2003-11-29 10:48 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
stallone_hwang wrote:
但此程式卻無法取得DataSource.....在JBuilder project中,請問在JBuilder中是應如何設定(JNDI/DataSource)?

ps.須把程式置於Tomcat webapp中才能跑,這樣的話JBuilder就無法發揮作用


參考看看:
1.Tool > Configure Server > 設定你的Tomcat Server. 指定給你的project.
jbuilder有預設幾個Tomcat Server.
他們的tomcat home都在JBUILDE_HOME/thirdparty/下面.
似乎可以把tomcat home指到外部.(不知道有沒有缺點.)
(jbuilder的opentool site找 tomcat-jbsp-4.x.jar 這個opetool.
可以多設其他的tomcat Server. 指到外部的Tomcat目錄)
2.想辦法找到你設定的tomcat裡面有個jbulder產生的conf/server8080.xml
請注意第二行註解. 請詳看該註解. 重點是把那行註解拿掉.
因為jbuilder會根據那行的存在與否來判斷是否可以在startup的時候
再產生一次server8080.xml
3.修改server8080.xml.
在 裡面加一個 ...其他就參考TomCat Document吧.

---
try & error.
fingerNail edited on 2003-11-29 10:51
作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
stallone_hwang





發文: 9
積分: 0
於 2003-12-02 16:00 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Dear fingerNail:
"server8080.xml"是在project folder下的Tomcat/conf中找到,在JBuilder Run前先放入,這樣便可使用其設定的JNDI。

ps.其他的設定依照上述即可
.....thanks
作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
scottlai





發文: 34
積分: 3
於 2003-12-02 23:58 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
/lib/ext/
另外還要
Jakarta Commons - DBCP
Jakarta Commons - Pool
(到 http://jakarta.apache.org/commons/index.html )

Tomcat4xTools.jar (38.41k)
作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
scottlai





發文: 34
積分: 3
於 2003-12-02 23:59 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
/lib/ext/

mot.jar (182.86k)
作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
scottlai





發文: 34
積分: 3
於 2003-12-03 00:00 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
scottlai





發文: 34
積分: 3
於 2003-12-03 00:01 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
scottlai





發文: 34
積分: 3
於 2003-12-03 00:02 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
scottlai





發文: 34
積分: 3
於 2003-12-03 00:05 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
javamon65





發文: 52
積分: 1
於 2003-12-03 10:47 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
小弟在 Jbuilder 8的做法大致如下
1. 確定[JBuilder_Home]/thirdparty/jakarta-tomcat-4.1.12-LE-jdk14/common/lib下,
有commons-collections.jar,commons-dbcp-1.1.jar,commons-pool-1.1.jar及所須要的jdbc檔案

2.接下來便是 tomcat 內的 server.xml的設定,
Jbuilder在啟動tomcat時,或許是為了要能run多個tomcat process,
會在特定目錄下({Project_Home}/Tomcat/conf)產生 serverxxxx.xml的檔案,
因為這些檔案是 generate dynamically,
為了要保留 JNDI 的相關設定,
因此在 Runtime configuration properties 下指定server parameter : -config 指定的server.xml (如附圖)

3.server.xml的內容












factory
org.apache.commons.dbcp.BasicDataSourceFactory


driverClassName
COM.ibm.db2.jdbc.app.DB2Driver


url
jdbc:db2:f901db01


username
db2admin


password
rl6002


maxActive
3


maxIdle
2


maxWait
-1











4.啟動tomcat,大公告成

p.s. :
1.tomcat 的 howto 中特別提到,jdbc也應該放在{$CATALINA_HOME}/common/lib,且不可是 zip的格式
2.感謝 ak47大大,有那篇分享我是成功的http://www.javaworld.com.tw/jute/post/view?bid=7&id=23499&sty=2
javamon65 edited on 2003-12-03 10:54
作者Re:請問如何在JBuilder中使用TomCat中設定的DataSource [Re:stallone_hwang]
seava





發文: 16
積分: 2
於 2004-04-02 15:47 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
這是我在JBuilder X 中試驗成功的步驟
1. 檢查Jbuilder預設使用的 /common/lib/下有沒有
Commons-collections.jar
Commons-dbcp.jar
Commons-pool.jar
以及jdbc driver
2. 在project -> project properties -> paths -> Required Libraries 中 也把步驟一中的幾個jar加進去
3. Run -> Configurations -> Edit , 將Make project libraries available on run 打勾
點 Libraries , 將Libraries to deploy at runtime中每一項都打勾
4. 因為JBuilder 每次Run 的時候會重新在你的 /Tomcat/conf/ 中動態產生serverXXXX.xml (XXXX看Tomcat使用的port而定) , 因此你的DataSource設定無法保留
一個方法是將動態產生的serverXXXX.xml中第二行註解拿掉, 再將其內容改成你所需要的, 下次JBuilder就不會再動態產生這個檔案了
另一個方法是 Run -> Configurations -> Edit , 在Server parameters中 填入
-config 你的server.xml路徑

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


Powered by Powerful JuteForum® Version Jute 1.5 Pro
Copyright© 2002-2003 Rainman Zhu,Zua,Netboy,Scott. All Rights Reserved.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值