JSP问题,The value for the XXX is invalid.

zpinggg 2010-12-23 12:12:00
生成的DDbean.class,打开时提示“Invalid or corrupt jarfile”。为什么会出错呢?


index.jsp 前三行:
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
<%@ include file="top.htm"%>
<jsp:useBean id="conn" class="dbBean.DBBean" scope="session"/>

==============分割线==========
出错提示:


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

exception :
org.apache.jasper.JasperException: /index.jsp(3,0) The value for the useBean class attribute dbBean.DBBean is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
等等,后面一长串。
===========分割线========
下面是代码,然后生成的DDbean.class,打开时提示“Invalid or corrupt jarfile”。为什么会出错呢?

package dbBean;

import java.io.PrintStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DBBean
{
private String driverStr = "sun.jdbc.odbc.JdbcOdbcDriver";
private String connStr = "jdbc:odbc:mydbsource";
private Connection conn = null;
private Statement stmt = null;

public DBBean()
{
try
{
Class.forName(this.driverStr);
}
catch (ClassNotFoundException localClassNotFoundException) {
System.out.println(localClassNotFoundException.getMessage());
}
}

public void setDriverStr(String paramString) {
this.driverStr = paramString;
}

public void setConnStr(String paramString) {
this.connStr = paramString;
}

public ResultSet executeQuery(String paramString) {
ResultSet localResultSet = null;
try {
this.conn = DriverManager.getConnection(this.connStr);
this.stmt = this.conn.createStatement();
localResultSet = this.stmt.executeQuery(paramString);
}
catch (SQLException localSQLException) {
System.out.println(localSQLException.getMessage());
}
return localResultSet;
}

public int executeUpdate(String paramString) {
int i = 0;
try {
this.conn = DriverManager.getConnection(this.connStr);
this.stmt = this.conn.createStatement();
i = this.stmt.executeUpdate(paramString);
}
catch (SQLException localSQLException) {
System.out.println(localSQLException.getMessage());
}
return i;
}

public void close() {
try {
this.stmt.close();
this.conn.close();
}
catch (SQLException localSQLException) {
System.out.println(localSQLException.getMessage());
}
}
}
...全文
132 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zpinggg 2010-12-23
  • 打赏
  • 举报
回复
<jsp:useBean id="conn" class="dbBean.DBBean" scope="session"/>
这句话 应该没错吧。


用Myeclipse和java命令,把那个源代码生成了.class文件,为什么出错了啊?

package dbBean;

import java.io.PrintStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DBBean
{
private String driverStr = "sun.jdbc.odbc.JdbcOdbcDriver";
private String connStr = "jdbc:odbc:mydbsource";
private Connection conn = null;
private Statement stmt = null;

public DBBean()
{
try
{
Class.forName(this.driverStr);
}
catch (ClassNotFoundException localClassNotFoundException) {
System.out.println(localClassNotFoundException.getMessage());
}
}

public void setDriverStr(String paramString) {
this.driverStr = paramString;
}

public void setConnStr(String paramString) {
this.connStr = paramString;
}

public ResultSet executeQuery(String paramString) {
ResultSet localResultSet = null;
try {
this.conn = DriverManager.getConnection(this.connStr);
this.stmt = this.conn.createStatement();
localResultSet = this.stmt.executeQuery(paramString);
}
catch (SQLException localSQLException) {
System.out.println(localSQLException.getMessage());
}
return localResultSet;
}

public int executeUpdate(String paramString) {
int i = 0;
try {
this.conn = DriverManager.getConnection(this.connStr);
this.stmt = this.conn.createStatement();
i = this.stmt.executeUpdate(paramString);
}
catch (SQLException localSQLException) {
System.out.println(localSQLException.getMessage());
}
return i;
}

public void close() {
try {
this.stmt.close();
this.conn.close();
}
catch (SQLException localSQLException) {
System.out.println(localSQLException.getMessage());
}
}
}

24,918

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Apache
社区管理员
  • Apache
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧