tomcat里的数据池配置是否正确?你的代码怎么写的?
解决方案 »
- 谁知道现在公司spring用xml写的多还是annotation的多啊
- java是否有办法生成带有vba脚本的Excel啊?
- 求救!Class.forName("com.mysql.jdbc.Driver").newInstance(); 说forName处语法错误。
- 菜鸟小问题!
- servlet怎么调用javabean?
- 使用Struts的FormFile上传文件,如何判断文件是否存在
- 我想做个发短信的东西,应该怎么做呢?
- 请问用struts做报表选择什么样的报表软件比较好?
- 求weblogic+jbuilder9+oracle9的开发实例(使用EJB)
- weblogic安装问题,为什么进入console后,左边的快速导航栏是空的,只有一个打叉 的图片?
- tomcat运行struts提示java.lang.ClassNotFoundException异常
- 用JDBC连接MS SQL SERVERR的问题
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/> <GlobalNamingResources> <Environment name="simpleValue" type="java.lang.Integer" value="30"/> <Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams> </GlobalNamingResources> <Service name="Catalina">
<Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" /> <Connector port="8009"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" />
<Engine name="Catalina" defaultHost="localhost" debug="0"> <Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/> <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase"/>
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<Context path="" docBase="ROOT" debug="0" reloadable="true" crossContext="true">
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev</value>
</parameter>
<parameter>
<name>username</name>
<value>sa</value>
</parameter>
<parameter>
<name>password</name>
<value>abc</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>80</value>
</parameter>
</ResourceParams>
</Context>
</Host> </Engine> </Service></Server>
<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.sql.*, javax.naming.*"%>
<%
try {
Context initCtx = new InitialContext();
Context ctx = (Context) initCtx.lookup("java:comp/env");
Object obj = (Object) ctx.lookup("jdbc/TestDB");
javax.sql.DataSource ds = (javax.sql.DataSource)obj;
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,
java.sql.ResultSet.CONCUR_READ_ONLY);
String strSQL = "SELECT * FROM test";
ResultSet rs = stmt.executeQuery(strSQL);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
...
</html>
<%
rs.close();
stmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
%>
挨!
在应用的 web.xml 文件中是否添加如下 DataSource 声名:
<resource-ref>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
configuration under Windows XP, there is no problem. Using the same
application under Tomcat 4.1.27, there is no problem (either Linux or
Windows).
As you can see from the included stack trace, I am using Hibernate which
is accessing the configured DataSource in a Servlet Filter at
application startup.
I have searched for this problem on this Mailing List, but got no clue.
I am using a Context local DataSource (no Global), and have everything
strictly setup as described in the JNDI HowTo. Given the number of
people that could not solve the problem, maybe there is a bug in Tomcat5?