⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tomcat全局数据源配置常见的错误--星溪.htm

📁 关于在Tomcat中配置数据库连接池的方法,附有相关的例子
💻 HTM
📖 第 1 页 / 共 2 页
字号:
style="COLOR: blue">jdbc/global</SPAN>");<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; mso-bidi-font-size: 14.0pt"><SPAN 
style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Connection conn = 
ds.getConnection();<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=ZH-CN 
style="FONT-SIZE: 10pt; FONT-FAMILY: SimSun; mso-bidi-font-size: 14.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">结果抛出</SPAN>javax.naming.NameNotFoundException: 
name global is not bound in this context. </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=ZH-CN 
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为什么定义了一个</SPAN>Global 
source<SPAN lang=ZH-CN 
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">却不能用呢?</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=ZH-CN 
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">原因是没有在引用全局</SPAN>DataSource<SPAN 
lang=ZH-CN 
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">资源的</SPAN>Web<SPAN 
lang=ZH-CN 
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">模块使用</SPAN>ResourceLink<SPAN 
lang=ZH-CN 
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">!</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=ZH-CN 
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</SPAN>webapp<SPAN 
lang=ZH-CN 
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN>context<SPAN 
lang=ZH-CN 
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">下添加如下</SPAN>ResourceLink<SPAN 
lang=ZH-CN 
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就</SPAN>OK<SPAN 
lang=ZH-CN 
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">了。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; mso-bidi-font-size: 14.0pt">&lt;Context path=”/webapp” 
reloadable=”true”&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; mso-bidi-font-size: 14.0pt"><SPAN 
style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>&lt;ResourceLink 
global="<SPAN style="COLOR: blue">jdbc/global</SPAN>" name="<SPAN 
style="COLOR: red">jdbc/myds</SPAN>" 
type="javax.sql.DataSource"/&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; mso-bidi-font-size: 14.0pt">&lt;/Context&gt;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=ZH-CN 
style="FONT-SIZE: 10pt; FONT-FAMILY: SimSun; mso-bidi-font-size: 14.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然后在</SPAN><SPAN 
style="FONT-SIZE: 10pt; mso-bidi-font-size: 14.0pt">webapp</SPAN><SPAN 
lang=ZH-CN 
style="FONT-SIZE: 10pt; FONT-FAMILY: SimSun; mso-bidi-font-size: 14.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">程序里这样使用:</SPAN><SPAN 
style="FONT-SIZE: 10pt; mso-bidi-font-size: 14.0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; mso-bidi-font-size: 14.0pt"><SPAN 
style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>Context initCtx = new 
javax.naming.InitialContext();<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; mso-bidi-font-size: 14.0pt"><SPAN 
style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>DataSource ds = 
(javax.sql.DataSource)initCtx.lookup("java:comp/env/<SPAN 
style="COLOR: red">jdbc/myds</SPAN>");<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; mso-bidi-font-size: 14.0pt"><SPAN 
style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Connection conn = 
ds.getConnection();<o:p></o:p></SPAN></P>
<P><SPAN lang=ZH-CN 
style="FONT-SIZE: 10pt; FONT-FAMILY: SimSun; mso-bidi-font-size: 14.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-fareast-language: ZH-CN; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">注意,</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 14.0pt; mso-font-kerning: 1.0pt; mso-fareast-language: ZH-CN; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: SimSun">JNDI</SPAN><SPAN 
lang=ZH-CN 
style="FONT-SIZE: 10pt; FONT-FAMILY: SimSun; mso-bidi-font-size: 14.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-fareast-language: ZH-CN; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">名应使用</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 14.0pt; mso-font-kerning: 1.0pt; mso-fareast-language: ZH-CN; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: SimSun">&lt;ResourceLink/&gt;</SPAN><SPAN 
lang=ZH-CN 
style="FONT-SIZE: 10pt; FONT-FAMILY: SimSun; mso-bidi-font-size: 14.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-fareast-language: ZH-CN; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">里的</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 14.0pt; mso-font-kerning: 1.0pt; mso-fareast-language: ZH-CN; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: SimSun">name</SPAN><SPAN 
lang=ZH-CN 
style="FONT-SIZE: 10pt; FONT-FAMILY: SimSun; mso-bidi-font-size: 14.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-fareast-language: ZH-CN; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">值而不是</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 14.0pt; mso-font-kerning: 1.0pt; mso-fareast-language: ZH-CN; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: SimSun">Global 
resource</SPAN><SPAN lang=ZH-CN 
style="FONT-SIZE: 10pt; FONT-FAMILY: SimSun; mso-bidi-font-size: 14.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-fareast-language: ZH-CN; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">里的</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 14.0pt; mso-font-kerning: 1.0pt; mso-fareast-language: ZH-CN; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: SimSun">name</SPAN><SPAN 
lang=ZH-CN 
style="FONT-SIZE: 10pt; FONT-FAMILY: SimSun; mso-bidi-font-size: 14.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-fareast-language: ZH-CN; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">值!</SPAN></P>
<P></P>
<P class=diaryFoot>- 作者: <A title=moonstariver 
onclick="window.open('/control/postMessage.b?receiverName=moonstariver&amp;receiver=29287','发送短消息','width=310,height=265')" 
href="javascript:void(0);">moonstariver</A> 2004年08月19日, 星期四 17:52 </P></DIV>
<DIV class=operation><A name=trackback>
<H3>Trackback</H3></A>
<P class=trackback>你可以使用这个链接引用该篇日志 
http://publishblog.blogdriver.com/blog/tb.b?diaryID=289294 </P></DIV>
<DIV class=operation><A name=comment>
<H3>回复</H3></A><A name=comment$(remark.remarkID)>
<H4>- 评论人:Lauray </H4></A>
<H5>Fri Apr 15 18:10:08 CST 2005  <A href="mailto:guofan0422@163.com"><IMG 
class=imgStyle height=12 alt=作者邮箱 src="Tomcat全局数据源配置常见的错误--星溪.files/letter.gif" 
width=16 align=absMiddle border=0></A>  <A href="http:///" target=_blank><IMG 
class=imgStyle height=14 alt=作者Blog 
src="Tomcat全局数据源配置常见的错误--星溪.files/blog_2.gif" width=16 align=textTop 
border=0></A> </H5><BR>
<P 
class=comment>我的tomcat为什么不能连oracle数据库呀!我的slf配置都对的呀!!!请大家看看有什么不对的地方,请给小妹发邮件,小妹先谢过了。!! 
<BR>这是配置 
<BR>CLASSSPAHT----------&gt;.;D:\j2sdk1.4.2_04\lib;D:\j2sdk1.4.2_04\dt.jar;D:\j2sdk1.4.2_04\tools.jar;D:\j2sdk1.4.2_04\lib\classes12.jar;D:\j2sdk1.4.2_04\jre\lib;D:\j2sdk1.4.2_04\jre\lib\servlet.jar;D:\j2sdk1.4.2_04\scr.zip;D:\Tomcat 
5.0\webapps\WRL\WEB-INF\classes 
<BR><BR>JAVA_HOME-------------&gt;D:\j2sdk1.4.2_04 
<BR>PATH------------------&gt;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;.;D:\j2sdk1.4.2_04\bin;<BR><BR></P><A 
name=comment$(remark.remarkID)>
<H4>- 评论人:匿名 </H4></A>
<H5>Mon Dec 27 20:35:51 CST 2004  <A href="http:///" target=_blank><IMG 
class=imgStyle height=14 alt=作者Blog 
src="Tomcat全局数据源配置常见的错误--星溪.files/blog_2.gif" width=16 align=textTop 
border=0></A> </H5><BR>
<P class=comment><IMG src="Tomcat全局数据源配置常见的错误--星溪.files/em40.htm" align=middle 
border=0><BR><BR></P></DIV>
<DIV class=operation>
<TABLE class=comment cellSpacing=0 cellPadding=0 width=700 border=0>
  <FORM id=replyForm method=post><INPUT type=hidden value=21400 name=blogID> 
  <INPUT type=hidden value=289294 name=diaryID> <INPUT type=hidden 
  value=moonstariver name=blogDomino>
  <SCRIPT>
if(getCookie('userID') == null){        
document.write('<tr><td width="70">发布人:</td>');
document.write('<td width="150"> <input name="remark.authorNameFUI" type="text" size="20" class="inputStyle" maxlength="20"></td>');
document.write('<td width="70">邮箱:</td>');
document.write('<td width="435"> <input name="remark.authorEmail" type="text" size="20" class="inputStyle" maxlength="40"></td>');
document.write('</tr><tr><td>主 页:</td>');
document.write('<td colspan="3"> <input name="remark.authorURL" type="text" class="inputStyle" value="HTTP://" size="63" maxlength="40"></td></tr>');
}else{
document.write('<input type="hidden" name="remark.authorNameFUI" value="Blogdriver">');
}
</SCRIPT>
   
  <TBODY>
  <TR align=left>
    <TD colSpan=4>评论内容:<BR><TEXTAREA class=textStyle id=remark name=remark.remarkFUI rows=8 cols=60>          </TEXTAREA> 
    </TD></TR>
  <TR align=left>
    <TD colSpan=4>              <INPUT onclick=reply() type=button value=提交>   
<INPUT type=reset value=重置> </TD></TR></FORM></TBODY></TABLE></DIV></DIV>
<SCRIPT src="" type=text/javascript></SCRIPT>

<DIV id=footer><A href="http://www.blogdriver.com/jsp/reg/register.jsp"><IMG 
class=logo src="Tomcat全局数据源配置常见的错误--星溪.files/logo3.gif" border=0></A><A 
href="http://www.blogdriver.com/">2003-2004 BLOGDRIVER.COM All rights 
reserved</A></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -