此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【zhao9302】截止到2008-07-26 20:50:35的历史汇总数据(不包括此帖):
发帖的总数量:4 发帖的总分数:70 每贴平均分数:17
回帖的总数量:4 得分贴总数量:1 回帖的得分率:25%
结贴的总数量:4 结贴的总分数:70
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:0.00 % 无满意结分率:0.00 %
敬礼!
楼主【zhao9302】截止到2008-07-26 20:50:35的历史汇总数据(不包括此帖):
发帖的总数量:4 发帖的总分数:70 每贴平均分数:17
回帖的总数量:4 得分贴总数量:1 回帖的得分率:25%
结贴的总数量:4 结贴的总分数:70
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:0.00 % 无满意结分率:0.00 %
敬礼!
解决方案 »
- 多进程同时访问一个文件的问题
- 用java实现二叉树排序
- Struts2中,在一行内显示多个select,怎么让3个年,月,日的select标签平行显示在一行。
- java webservice 怎样得到客户端IP地址
- 求救一个ant编译代码的问题
- Weblogic 如果 ShutDown了,如何让它自动Start
- 请教大家一个关于 windows 和 linux 下的中文问题?
- struts的validator怎么就不行呢?到底是哪里不对了????
- socket 与 winsock通信问题,请帮忙!
- Mapped Statements collection does not contain value for
- 请教一个关于spring+struts+hibernate 写入oracle CLOB字段的问题
- jsp+servlet+javabean的分页显示,进来给点思路,谢谢! 100分
17:
18: InitialContext ic = new InitialContext();
19: DataSource ds = (DataSource)ic.lookup("java:comp/env/jdbc/bbs");
20: Connection conn = ds.getConnection();
21: Statement stmt = conn.createStatement();
22: String sql = "select * from article ";
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause javax.servlet.ServletException: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.TestDatabase_jsp._jspService(TestDatabase_jsp.java:122)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
org.apache.naming.NamingContext.lookup(NamingContext.java:770)
org.apache.naming.NamingContext.lookup(NamingContext.java:140)
org.apache.naming.NamingContext.lookup(NamingContext.java:781)
org.apache.naming.NamingContext.lookup(NamingContext.java:140)
org.apache.naming.NamingContext.lookup(NamingContext.java:781)
org.apache.naming.NamingContext.lookup(NamingContext.java:153)
org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
javax.naming.InitialContext.lookup(Unknown Source)
org.apache.jsp.TestDatabase_jsp._jspService(TestDatabase_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
--------------------------------------------------------------------------------Apache Tomcat/6.0.16
可能是我的程序也有点问题,但是不知道应该怎么弄才对。。请指教
path是你的web应用发布名吗?docBase是你的系统的当地目录吗(如:c:\**\你的系统目录)?Exception说"Name jdbc is not bound in this Context"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/bbs"
username="root"
password="root"
maxActive="50"
maxIdle="20"
maxWait="10000" /> </Context>
添加 <resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
这是获得Connection的代码 package xushun.util;import java.sql.*;
import javax.sql.*;
import javax.naming.*;public class DBHelper {
public static Connection getConnection() throws SQLException ,NamingException
{
// 初始化查找命名空间
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
// 找到DataSource
DataSource ds = (DataSource)envContext.lookup("jdbc/mysql");
return ds.getConnection();
}}
呵呵 ,我也是正在做bbs项目
又来了 Cannot create JDBC driver of class '' for connect URL 'null' 郁闷 这到底咋回事 。。郁闷。。
我在 WEB-INF 下加了
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/bbs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
可以解决前面的问题
哎 要不有谁能把完整的Tomcat6.0的 数据库连接池 配置发来
lib目录下面, OK
Connection conn = null;Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");conn = DriverManager.getConnection("proxool.example1:org.gjt.mm.mysql.Driver:jdbc:mysql://localhost:3306/test1","root","111111");
就改这么点东西就行了,驱动改成他这个,然后把MYSQL或者是要用的数据库的驱动写到getConnection里的proxool.example1:后面proxool.example1:中的example1是连接池的名字,你可以按照你的需求改http://proxool.sourceforge.net/这个是proxool的网址我测试过了用了这个连接池,本地测试啊链接100次用了1.7秒不用连接池33秒左右用连接池1000次 6秒多不用连接池。。我没敢测
<Resource name="jdbc/bbs"
auth="Container" type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
maxIdle="20"
maxWait="5000"
username="root"
password="admin"
url="jdbc:mysql://localhost:3306/bbs"
maxActive="100"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true"/> 在Context下写:
<ResourceLink name="jdbc/bbs" global="jdbc/bbs" type="javax.sql.DataSource"/> 再调用即可
<Resource
name="jdbc/mysql"
type="javax.sql.DataSource"
driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
url="jdbc:mysql://localhost:3306/qq"
username="root"
password="111111"
maxActive="50"
maxIdle="10"
maxWait="10000"
removeAbandonedTimeout="5"/>
web.xml
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/mysql></res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>