标题:用javabean连接sql 2000连接不上(已解决,配置有问题)
只看楼主
pchelp2008
Rank: 1
等 级:新手上路
威 望:1
帖 子:177
专家分:0
注 册:2006-8-2
 问题点数:0 回复次数:28 
用javabean连接sql 2000连接不上(已解决,配置有问题)

现在又出现了这样的错误:这是找不到什么来着:是不是配置有问题呢:
--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /11.jsp(3,5) Invalid standard action
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.apache.jasper.JasperException: /11.jsp(3,5) Invalid standard action
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:86)
org.apache.jasper.compiler.Parser.parseStandardAction(Parser.java:1258)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1572)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.


--------------------------------------------------------------------------------

这是firm.java文件
package firm;

import java.sql.*;
import java.io.*;
import java.util.*;

public class firm
{
public Connection conn = null;
public Statement stmt = null;
public ResultSet rs = null;
// private static String propFileName = "C:/connDB.properties";
// private static Properties prop = new Properties();
private static String dbClassName ="com.microsoft.jdbc.sqlserver.SQLServerDriver";
private static String dbUrl ="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=GuestBook";
private static String dbUser = "sa";
private static String dbPwd = "";

public static Connection getConnection()
{
Connection conn = null;
try
{
Class.forName(dbClassName).newInstance();
conn = DriverManager.getConnection(dbUrl, dbUser, dbPwd);
}
catch (Exception ee)
{
ee.printStackTrace();
}
if (conn == null)
{
System.err.println(
);
}
return conn;
}

/*
*功能:执行查询语句
*/
public ResultSet executeQuery(String sql)
{
try
{
conn = getConnection();
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
}
catch (SQLException ex)
{
System.err.println(ex.getMessage());
}
return rs;
}

/*
*功能:执行更新操作
*/
public int executeUpdate(String sql)
{
try
{
conn = getConnection();
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
result = stmt.executeUpdate(sql);
}
catch (SQLException ex)
{

}
try
{
stmt.close();
}
catch (SQLException ex1)
{
}
}
/*
*功能:关闭数据库的连接
*/
public void close()
{
try
{
if (rs != null)
{
rs.close();
}
}
catch (Exception e)
{
e.printStackTrace(System.err);
}
try
{
if (stmt != null)
{
stmt.close();
}
}
catch (Exception e)
{
e.printStackTrace(System.err);
}
try
{
if (conn != null)
{
conn.close();
}
}
catch (Exception e)
{
e.printStackTrace(System.err);
}
}

}


这是index.jsp文件:

<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.sql.*,java.text.*,java.util.*,HYBTX.sys.data.*,HYBTX.info.*"%>
<jsp:userBean id="conn" scope="page" class="firm.firm"/>
<%
String sql="select * from Guest_Book";
ResultSet rs=conn.executeQuery(sql);
out.print(rs);
%>

[此贴子已经被作者于2006-9-18 13:17:29编辑过]



rZCe5nXW.bmp (157.25 KB)
搜索更多相关主题的帖子: javabean sql 
2006-09-13 12:43
roy_guo
Rank: 1
等 级:新手上路
帖 子:107
专家分:0
注 册:2006-4-27
得分:0 
报的错贴出来
安装jdbc驱动和SQLServer补丁了么?

彪悍的人生不需要解释~~~
2006-09-13 13:15
pchelp2008
Rank: 1
等 级:新手上路
威 望:1
帖 子:177
专家分:0
注 册:2006-8-2
得分:0 
大家光看不回答呢!!是不是太简单了啊!

天才=勤奋+汗水ggggggggggggggggg
2006-09-13 13:15
pchelp2008
Rank: 1
等 级:新手上路
威 望:1
帖 子:177
专家分:0
注 册:2006-8-2
得分:0 
装了啊!!!!!!!什么都没报,就是一个null

[此贴子已经被作者于2006-9-13 13:19:52编辑过]


天才=勤奋+汗水ggggggggggggggggg
2006-09-13 13:16
球球
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:1146
专家分:265
注 册:2005-11-28
得分:0 
晕晕晕,把数据库部分搞得也太详细了...

[此贴子已经被作者于2006-9-13 14:05:01编辑过]


好累
2006-09-13 14:04
球球
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:1146
专家分:265
注 册:2005-11-28
得分:0 
你尝试下在jsp中调用ResultSet executeQuery(String sql)这个方法.


//while(rs.next()){
//String ID=rs.getString("ID");
//out.print(ID);
//}
把String ID定义在外面,试试.

[此贴子已经被作者于2006-9-13 14:34:33编辑过]


好累
2006-09-13 14:08
pchelp2008
Rank: 1
等 级:新手上路
威 望:1
帖 子:177
专家分:0
注 册:2006-8-2
得分:0 

还是没效果啊.它压根儿就没连上啊!我的配置应该没问题

[此贴子已经被作者于2006-9-14 8:19:50编辑过]


天才=勤奋+汗水ggggggggggggggggg
2006-09-14 08:02
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
得分:0 
ResultSet rs=conn.executeQuery(sql);这句
应该是ResultSet rs=st.executeQuery(sql);

win32汇编
病毒 加密
目前兴趣所在
2006-09-14 10:16
pchelp2008
Rank: 1
等 级:新手上路
威 望:1
帖 子:177
专家分:0
注 册:2006-8-2
得分:0 


我用了:ResultSet rs=conn.executeQuery(sql);这句
应该是ResultSet rs=st.executeQuery(sql);
出现了这个:,没定义呢:
An error occurred at line: 4 in the jsp file: /index.jsp
Generated servlet error:
st cannot be resolved


org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause


天才=勤奋+汗水ggggggggggggggggg
2006-09-14 11:25
pchelp2008
Rank: 1
等 级:新手上路
威 望:1
帖 子:177
专家分:0
注 册:2006-8-2
得分:0 

烦死了:改成这样也不行:
package firm;
import java.sql.*;
public class firm {
String sDbDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String sConnStr = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=GuestBook";
String user = "sa";
String pass = "";
private Connection conn=null;
private Statement stmt=null;
ResultSet rs=null;

public firm(){
try {
Class.forName(sDbDriver);
}
catch(java.lang.ClassNotFoundException e){
System.err.println("firm():"+e.getMessage());
}
}
////////////////////////////////////
public ResultSet executeQuery(String sql){
//rs=null;
try
{
conn=DriverManager.getConnection(sConnStr,user,pass);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(sql);
//System.out.println("连接数据库成功");
}
catch(SQLException ex)
{
System.err.println("aq.executeQuery:"+ex.getMessage());
//System.out.println("发生异常");
//return null;
}
return rs;
}

//////////////////////////////
public int executeUpdate(String sql)
{
//stmt=null;
//rs=null;
int result = 0;
try{

conn=DriverManager.getConnection(sConnStr,user,pass);
stmt=conn.createStatement();
result=stmt.executeUpdate(sql);
//stmt.close();
//conn.close();


}
catch(SQLException ex)
{
result = 0;
//System.err.println("aq.executeQuery:"+ex.getMessage());
}

try {
stmt.close();
}
catch(SQLException ex1)
{
}
return result;
}
////////////////////////////////////////
public void close(){
try{
if (rs != null){
rs.close();
}
}
catch(Exception e){
// e.printStackTrace(system.err);
}
try
{
if (stmt != null)
{
stmt.close();
}
}
catch (Exception e)
{
// e.printStackTrace(system.err);
}
try
{
if (conn != null)
{

conn.close();
}

}
catch (Exception e)
{
// e.printStackTrace(system.err);
}
}
}







[此贴子已经被作者于2006-9-18 12:53:11编辑过]


天才=勤奋+汗水ggggggggggggggggg
2006-09-14 12:58



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-89906-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.160819 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved