数据库问题

古月书斋 2004-05-06 01:04:56
小弟写了一个JAVABEAB:package bookship;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.io.*;
import java.sql.Date;
public class UserRegist implements Serializable {
private UserBean userInfo;
private Connection con;
public UserRegist() {
}
public void setUserInfo(UserBean userInfo)
{
this.userInfo=userInfo;
//得到用户信息;
}
public void setConnnectoin(Connection con)
{
this.con=con;
}

public void regist()throws Exception
{ if(con==null)
return;
String reg="insert into user_info values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
try
{
PreparedStatement pstmt=con.prepareStatement(reg);
pstmt.setString(1,"2");
pstmt.setString(2,"2");
pstmt.setString(3,"3");
pstmt.setString(4,"2");
pstmt.setString(5,"5");
pstmt.setString(6,"4");
pstmt.setString(7,"7");
pstmt.setString(8,"8");
pstmt.setString(9,"9");
pstmt.setInt(10,1);

pstmt.setInt(11,0);
pstmt.setDate(12,new java.sql.Date(new java.util.Date().getTime()));
pstmt.setInt(13,1);
pstmt.setInt(14,0);
pstmt.setString(15,"12");
pstmt.setString(16,"13");
pstmt.executeUpdate();
con.close();
}
catch(Exception e)
{ con.close();
e.printStackTrace();
throw e;
}
}
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject();
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
}

}
我用.jsp测试不成功.<%@ page contentType="text/html; charset=GBK" import="bookship.*,java.sql.*"%>
<html>
<head>
title>用户信息注册页面</title>
</head>
<jsp:useBean id="dataBean" scope="session" class="bookship.DatabaseBean" />
<jsp:useBean id="UserInfo" scope="session" class="bookship.UserBean" />
<jsp:setProperty name="UserInfo" property="*" />
<jsp:useBean id="regist" scope="session" class="bookship.UserRegist" />
<LINK href="hellking.css" type=text/css rel=stylesheet>
<body><%
regist.setUserInfo(UserInfo);
regist.setConnnectoin(dataBean.getConnection());
regist.regist();
<a href="main.jsp">返回</a>
</body>
</html>
我通过测试dataBean.getConnection()没有问题.
...全文
71 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
古月书斋 2004-05-06
  • 打赏
  • 举报
回复
谢谢各位!我的问题解决了.原来我建数据库的时候少建了一列.
Arias 2004-05-06
  • 打赏
  • 举报
回复
察看后台的显示情况,一般出现这种情况的时候应该根据后台的异常信息来定位出错的地方!·
minghuitian 2004-05-06
  • 打赏
  • 举报
回复
up
hui3zhihui 2004-05-06
  • 打赏
  • 举报
回复
数据库问题里面肯定是要捕获SQLException的,你可能事没有捕获这个异常
rainight 2004-05-06
  • 打赏
  • 举报
回复
出现这类问题,你一般不要看浏览器抛出的错误信息,多半是没有用的,应该看看控制台tomcat抛出什么Exception,贴过来
古月书斋 2004-05-06
  • 打赏
  • 举报
回复
我的页面提示为:Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

67,514

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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