| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1474 人关注过本帖
标题:JSP连数据库错误
只看楼主 加入收藏
しΟν∈→鱈
Rank: 1
等 级:新手上路
威 望:2
帖 子:369
专家分:0
注 册:2006-10-25
收藏
 问题点数:0 回复次数:26 
JSP连数据库错误

HTTP Status 500 -


type Exception report

message

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

exception

org.apache.jasper.JasperException
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NullPointerException
    org.apache.jsp.register.register_jsp._jspService(register_jsp.java:71)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

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

什么意思哦。。。

搜索更多相关主题的帖子: 数据库 JSP ffffff 
2007-01-23 14:01
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
收藏
得分:0 
写着空指针异常呢啊

win32汇编
病毒 加密
目前兴趣所在
2007-01-23 14:03
しΟν∈→鱈
Rank: 1
等 级:新手上路
威 望:2
帖 子:369
专家分:0
注 册:2006-10-25
收藏
得分:0 

知道啊  但是不知道去哪找哎。。。


开开心心的过&玩每一天!!!!
2007-01-23 14:04
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
收藏
得分:0 

你自己都找不到 别人怎么能找到呢


win32汇编
病毒 加密
目前兴趣所在
2007-01-23 14:07
しΟν∈→鱈
Rank: 1
等 级:新手上路
威 望:2
帖 子:369
专家分:0
注 册:2006-10-25
收藏
得分:0 
不是啊   这个上面的提示好像都不是我的程序里的啊。。
要不我帖上我的代码   版主帮我看下喽


开开心心的过&玩每一天!!!!
2007-01-23 14:11
しΟν∈→鱈
Rank: 1
等 级:新手上路
威 望:2
帖 子:369
专家分:0
注 册:2006-10-25
收藏
得分:0 
[CODE]

DBConnect代码:
package com.simon.db;

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

public class DBConnect {

public DBConnect() {
}

public static Connection getConnection() {
ResourceBundle rb = ResourceBundle.getBundle("db");

try {
String driverName = rb.getString("db.driver");
Driver dirver = (Driver)Class.forName(driverName).newInstance();
String url = rb.getString("db.url");
Connection con = DriverManager.getConnection(url);
return con;

} catch(ClassNotFoundException cnfExc) {
System.out.println(cnfExc.getMessage());
cnfExc.printStackTrace();

} catch(SQLException sqlExc) {
System.out.println(sqlExc.getMessage());
sqlExc.printStackTrace();

} catch(IllegalAccessException e) {
System.out.println(e.getMessage());
e.printStackTrace();
} catch(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
return null;
}

public static void main(String[] args) throws Throwable{
//Connection con = getConnection();
//Statement stmt = con.createStatement();
}
}

[/CODE]

开开心心的过&玩每一天!!!!
2007-01-23 14:14
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
收藏
得分:0 
应该是你的程序有问题 向数据库插入数据常常出现空指针异常
仔细检查 就可以了
(我可不是这个版的斑竹

win32汇编
病毒 加密
目前兴趣所在
2007-01-23 14:15
しΟν∈→鱈
Rank: 1
等 级:新手上路
威 望:2
帖 子:369
专家分:0
注 册:2006-10-25
收藏
得分:0 
[CODE]

register2.jsp代码:
<%@ page language="java" import="java.sql.*" pageEncoding="gb2312" errorPage=""%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<base href="http://localhost:8080/JSPExercise/">

<title>My JSP 'regist2.jsp' page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body background="../PIC/bg2.jpg">
<form name = "register" action = "register/register.jsp" method = "post">
<TABLE cellSpacing="0" cellPadding="0" width="610" align="center" border="0">
<tr>
<td width="610" height="50"><font size="4" color="#2d5bbb">&nbsp;注册步骤:
1.阅读使用手册 -> <font color=red>2.选择用户名,填写个人资料 </font>-> 3.注册成功</font></table>
<tr>
<TABLE cellSpacing="0" cellPadding="0" width="492" align="center" border="0">
<tr>
<td width="86" height="42"> 用户名:
<td width="406"><input type = "text" name = "name" size = "20"><font color="red">*(你在班级的真实姓名)</font>
<tr>
<td width="86" height="42">密码:
<td><input type = "password" name = "password" size = "20"><font color="red">*(你的学号)</font>
<tr>
<td width="86" height="42">确认密码:
<td><input type = "password" name = "checkpassword" size = "20"><font color="red">*</font>
<tr>
<td height="20">性别
<td>男 <input type = "radio" name = "sex" checked="checked">
  女 <input type = "radio" name = "sex"><font color="red">*</font>
<tr>
</table>
<br><table width="495" height="130" align = "center">
<tr>联系方式:<br><br>
<td width="492">
<p>1:手机号码: <input type = "text" name = "mobelphone" size = "20"><br><br>
2:QQ号码:  <input type = "text" name = "QICQ" size = "20"><br><br>
3:邮箱:  <input type = "text" name = "E-mail" size = "20"><br><br>
4:详细住址: 
<input type = "text" name = "province" size = "10">省
<input type = "text" name="city" size="10">市
<input type = "text" name = "street" size = "20"><br>
<p align = "center"><font color = "#2d5bbb">带*号的必填,联系方式好歹给个面子填上一个吧!</font></p>
</table>
<p align = "center"><input type = "image" src = "PIC/commit2.gif">
</form>
</body>
</html>

[/CODE]

开开心心的过&玩每一天!!!!
2007-01-23 14:15
しΟν∈→鱈
Rank: 1
等 级:新手上路
威 望:2
帖 子:369
专家分:0
注 册:2006-10-25
收藏
得分:0 
[CODE]register.jsp代码:
<%@ page language="java" import="com.simon.db.*,java.sql.*,java.util.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
String name = request.getParameter("name");
String ID = request.getParameter("password");
String checkID = request.getParameter("checkpassword");
String sex = request.getParameter("sex");
String mobelphone = request.getParameter("mobelphone");
String qq = request.getParameter("QICQ");
String Email = request.getParameter("E-mail");
String province = request.getParameter("province");
String city = request.getParameter("city");
String SQLCommand = "insert into Student_info values('"
+ ID + "', " + 1 + ", '" + province + "', '" + city + "', "
+ null + "', '" + mobelphone + "', '" + qq + "', '" + Email +"');";
%>
<%
Connection con = DBConnect.getConnection();
Statement stmt = con.createStatement();
stmt.execute(SQLCommand);
con.close();
response.sendRedirect("register/registersuccess.jsp");
%>
[/CODE]

开开心心的过&玩每一天!!!!
2007-01-23 14:16
支离破碎
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:737
专家分:0
注 册:2007-1-4
收藏
得分:0 
一般空指针出现肯定是没对象你就在用,你看你页面表现的时候的一些操作,是否有值

人生漂泊無依,有如浮萍菱花,隨水飄流,你会在我这里停留吗?
[url=http://51mynet.]http://51mynet.[/url]
2007-01-23 14:17
快速回复:JSP连数据库错误
数据加载中...
 
   



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

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