首页上一页 1 下一页尾页 4 条记录 1/1页
《java项目全程实录》中BBS项目光盘中的程序应该是连mysql,程序中却是sqlserver字样?
发表在JavaWeb图书答疑
2009-02-23
是否精华
是
否
版块置顶:
是
否
《java项目全程实录》中BBS项目光盘中的程序按书中应该是连mysql数据库的,程序ConnDb.java
中却是sqlserver字样 ?
代码如下
package com.wsy.struts.datasource;
import java.sql.*;
public class ConnDB{
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
public ConnDB(){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(java.lang.ClassNotFoundException e){
System.err.println(e.getMessage());
}
}
/***************************************************
*method name: executeQuery()
*����:ִ�в�ѯ����
*return value: ResultSet
****************************************************/
public ResultSet executeQuery(String sql){
try{
conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_FABD06;user=sa;password=");
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(sql);
}catch(SQLException ex){
System.err.println(ex.getMessage());
}finally{}
return rs;
}
/***************************************************
*method name: executeUpdate()
*����:ִ�и��²���
*return value: int
****************************************************/
public int executeUpdate(String sql){
int result=0;
try{
conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_database10;user=sa;password=");
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
result=stmt.executeUpdate(sql);
}catch(SQLException ex){
result=0;
}finally{}
return result;
}
/***************************************************
*method name: close()
*����:�ر���ݿ�t��
*return value: void
****************************************************/
public void close(){
try {
if (rs != null) rs.close();
}
catch (Exception e) {
e.printStackTrace(System.err);
}finally{}
try {
if (stmt != null) stmt.close();
}
catch (Exception e) {
e.printStackTrace(System.err);
}finally{}
try {
if (conn != null) {
conn.close();
}
}
catch (Exception e) {
e.printStackTrace(System.err);
}finally{}
}
}
现在项目也运行不通,报HTTP Status 503 - Servlet action is currently unavailable
--------------------------------------------------------------------------------
type Status report
message Servlet action is currently unavailable
description The requested service (Servlet action is currently unavailable) is not currently available.
tomcat中启动时,报下信息:
2009-2-23 15:53:34 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.5.0_05\bin;C:\tomcat5.5\bin
2009-2-23 15:53:34 org.apache.coyote.http11.Http11BaseProtocol init
信息: Initializing Coyote HTTP/1.1 on http-8888
2009-2-23 15:53:34 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 937 ms
2009-2-23 15:53:34 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2009-2-23 15:53:34 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/5.5.27
2009-2-23 15:53:34 org.apache.catalina.core.StandardHost start
信息: XML validation disabled
2009-2-23 15:53:36 org.apache.struts.action.ActionServlet initModuleDataSources
严重: Initializing application data source dataSources
java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:117)
at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:805)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:927)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:890)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
2009-2-23 15:53:36 org.apache.catalina.core.ApplicationContext log
信息: Marking servlet action as unavailable
2009-2-23 15:53:36 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet /bbs threw load() exception
javax.servlet.UnavailableException: Initializing application data source dataSources
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:812)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:927)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:890)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
2009-2-23 15:53:36 org.apache.coyote.http11.Http11BaseProtocol start
信息: Starting Coyote HTTP/1.1 on http-8888
2009-2-23 15:53:36 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2009-2-23 15:53:36 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/47 config=null
2009-2-23 15:53:36 org.apache.catalina.storeconfig.StoreLoader load
信息: Find registry server-registry.xml at classpath resource
2009-2-23 15:53:37 org.apache.catalina.startup.Catalina start
信息: Server startup in 2609 ms
2009-2-23 15:54:01 org.apache.catalina.core.ApplicationDispatcher invoke
警告: Servlet action is currently unavailable
请问到底这个案例是连mysql还是ms sqlserver?我也急着用此案例。有解决方法,请尽快告诉我。邮箱742655775@qq.com
中却是sqlserver字样 ?
代码如下
package com.wsy.struts.datasource;
import java.sql.*;
public class ConnDB{
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
public ConnDB(){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(java.lang.ClassNotFoundException e){
System.err.println(e.getMessage());
}
}
/***************************************************
*method name: executeQuery()
*����:ִ�в�ѯ����
*return value: ResultSet
****************************************************/
public ResultSet executeQuery(String sql){
try{
conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_FABD06;user=sa;password=");
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(sql);
}catch(SQLException ex){
System.err.println(ex.getMessage());
}finally{}
return rs;
}
/***************************************************
*method name: executeUpdate()
*����:ִ�и��²���
*return value: int
****************************************************/
public int executeUpdate(String sql){
int result=0;
try{
conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_database10;user=sa;password=");
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
result=stmt.executeUpdate(sql);
}catch(SQLException ex){
result=0;
}finally{}
return result;
}
/***************************************************
*method name: close()
*����:�ر���ݿ�t��
*return value: void
****************************************************/
public void close(){
try {
if (rs != null) rs.close();
}
catch (Exception e) {
e.printStackTrace(System.err);
}finally{}
try {
if (stmt != null) stmt.close();
}
catch (Exception e) {
e.printStackTrace(System.err);
}finally{}
try {
if (conn != null) {
conn.close();
}
}
catch (Exception e) {
e.printStackTrace(System.err);
}finally{}
}
}
现在项目也运行不通,报HTTP Status 503 - Servlet action is currently unavailable
--------------------------------------------------------------------------------
type Status report
message Servlet action is currently unavailable
description The requested service (Servlet action is currently unavailable) is not currently available.
tomcat中启动时,报下信息:
2009-2-23 15:53:34 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.5.0_05\bin;C:\tomcat5.5\bin
2009-2-23 15:53:34 org.apache.coyote.http11.Http11BaseProtocol init
信息: Initializing Coyote HTTP/1.1 on http-8888
2009-2-23 15:53:34 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 937 ms
2009-2-23 15:53:34 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2009-2-23 15:53:34 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/5.5.27
2009-2-23 15:53:34 org.apache.catalina.core.StandardHost start
信息: XML validation disabled
2009-2-23 15:53:36 org.apache.struts.action.ActionServlet initModuleDataSources
严重: Initializing application data source dataSources
java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:117)
at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:805)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:927)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:890)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
2009-2-23 15:53:36 org.apache.catalina.core.ApplicationContext log
信息: Marking servlet action as unavailable
2009-2-23 15:53:36 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet /bbs threw load() exception
javax.servlet.UnavailableException: Initializing application data source dataSources
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:812)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:927)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:890)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
2009-2-23 15:53:36 org.apache.coyote.http11.Http11BaseProtocol start
信息: Starting Coyote HTTP/1.1 on http-8888
2009-2-23 15:53:36 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2009-2-23 15:53:36 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/47 config=null
2009-2-23 15:53:36 org.apache.catalina.storeconfig.StoreLoader load
信息: Find registry server-registry.xml at classpath resource
2009-2-23 15:53:37 org.apache.catalina.startup.Catalina start
信息: Server startup in 2609 ms
2009-2-23 15:54:01 org.apache.catalina.core.ApplicationDispatcher invoke
警告: Servlet action is currently unavailable
请问到底这个案例是连mysql还是ms sqlserver?我也急着用此案例。有解决方法,请尽快告诉我。邮箱742655775@qq.com