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

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

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


天才=勤奋+汗水ggggggggggggggggg
2006-09-14 08:02
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
pchelp2008
Rank: 1
等 级:新手上路
威 望:1
帖 子:177
专家分:0
注 册:2006-8-2
得分:0 

数据库表在最上面:只有两行:
数据库里有数据,只有两行:测试的:现在我又改了,还是不行:
出错如下:

type Exception report

message

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

exception

org.apache.jasper.JasperException: Exception in JSP: /index.jsp:6

3: <jsp:useBean id="conn" scope="page" class="firm.firm"/>
4: <%//st=conn.createStatement();
5: String sql="select * from Guest_Book";
6: ResultSet rs=conn.executeQuery(sql);
7: //ResultSet executeQuery(String sql);
8: //String ID=rs.getString("ID");
9: //while(rs.next()){


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
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

java.lang.NullPointerException
firm.firm.executeQuery(firm.java:68)
org.apache.jsp.index_jsp._jspService(index_jsp.java:60)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
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.


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


天才=勤奋+汗水ggggggggggggggggg
2006-09-14 17:40
pchelp2008
Rank: 1
等 级:新手上路
威 望:1
帖 子:177
专家分:0
注 册:2006-8-2
得分:0 
可以这样写,如果失败,它会返回一个小于0的数:

天才=勤奋+汗水ggggggggggggggggg
2006-09-15 08:04
pchelp2008
Rank: 1
等 级:新手上路
威 望:1
帖 子:177
专家分:0
注 册:2006-8-2
得分:0 
我还没明白,怎么连不上,连了两天还不行,郁闷!

[此贴子已经被作者于2006-9-15 12:14:59编辑过]



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

韩峰的main方法,我不知道怎么测,所以...........
我用了25楼的,出现这样的!它说50行有错误;
description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /11.jsp:6

3: <jsp:useBean id="firm" scope="page" class="firm.firm" />
4: <%
5: String sql="select * from Guest_Book";
6: ResultSet rs=firm.executeQuery(sql);
7: out.print(rs);
8: %>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
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

java.lang.NullPointerException
firm.firm.executeQuery(firm.java:50)

org.apache.jsp._11_jsp._jspService(_11_jsp.java:61)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
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)

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


天才=勤奋+汗水ggggggggggggggggg
2006-09-16 08:16



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




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

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