jsp报错,An exception occurred processing JSP page /user_add.jsp at line 129

Zeus 2011-07-10 12:39:16
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import ="com.drp.jdbc.util.*"%>
<%@ page import ="java.sql.*"%>

<%@ page import ="java.util.Date"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>添加用户</title>
<link rel="stylesheet" href="../style/drp.css">
<script src="../script/client_validate.js"></script>
<script type="text/javascript">
function goBack() {
window.self.location="user_maint.html"
}

function addUser() {

}
function Blur(){

}
</script>
</head>

<body class="body1">
<form name="userForm" target="_self" id="userForm">
<div align="center">
<table width="95%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td> 

</td>
</tr>
</table>
<table width="95%" border="0" cellspacing="0" cellpadding="0"
height="25">
<tr>
<td width="522" class="p1" height="25" nowrap>
<img src="../images/mark_arrow_03.gif" width="14" height="14">
 
<b>系统管理>>用户维护>>添加</b>
</td>
</tr>
</table>
<hr width="97%" align="center" size=0>
<table width="95%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="22%" height="29">
<div align="right">
<font color="#FF0000">*</font>用户代码: 
</div>
</td>
<td width="78%">
<input name="userId" type="text" class="text1" id="userId"
size="10" maxlength="10">
</td>
</tr>
<tr>
<td height="26">
<div align="right">
<font color="#FF0000">*</font>用户名称: 
</div>
</td>
<td>
<input name="userName" type="text" class="text1" id="userName"
size="20" maxlength="20">
</td>
</tr>
<tr>
<td height="26">
<div align="right">
<font color="#FF0000">*</font>密码: 
</div>
</td>
<td>
<label>
<input name="password" type="password" class="text1"
id="password" size="20" maxlength="20">
</label>
</td>
</tr>
<tr>
<td height="26">
<div align="right">
联系电话: 
</div>
</td>
<td>
<input name="contactTel" type="text" class="text1"
id="contactTel" size="20" maxlength="20">
</td>
</tr>
<tr>
<td height="26">
<div align="right">
email: 
</div>
</td>
<td>
<input name="email" type="text" class="text1" id="email"
size="20" maxlength="20">
</td>
</tr>
</table>
<hr width="97%" align="center" size=0>
<div align="center">
<input name="btnAdd" class="button1" type="button" id="btnAdd"
value="添加" onClick="addUser()">
    
<input name="btnBack" class="button1" type="button" id="btnBack"
value="返回" sonClick="goBack()" />
</div>
</div>
</form>
</body>
</html>
<%
Date date = new Date();
String id = request.getParameter("userId");
String name = request.getParameter("userName");
String psw = request.getParameter("password");
String sql = "insert into t_user(user_Id, USER_NAME,PASSWORD,CREATE_DATE) values ('" + id + "','" + name + "','" + psw + "','" + date +"')";
Connection conn=JdbcBean.getConnection();
Statement ps = conn.createStatement(); //错在这行,An exception occurred processing JSP page /user_add.jsp at line 129


ps.executeUpdate(sql);
%>
<%= sql%>



127: // String sql = "select * from t_user";
128: Connection conn=JdbcBean.getConnection();
129: Statement ps = JdbcBean.getStatment(conn);
130: ps.executeUpdate(sql);
131: %>
132: <%= sql%>


这是什么原因啊。
...全文
2993 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Zeus 2011-07-13
  • 打赏
  • 举报
回复
头晕中。
Zeus 2011-07-10
  • 打赏
  • 举报
回复
我写了另一个CLASS那时有连接数据库方法。
package com.drp.jdbc.util;
import java.sql.*;
public class JdbcBean{
public static void main(String[] args){
JdbcBean.getConnection();
}
static{

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
System.out.println("ClassNotFoundException");
e.printStackTrace();
}

}
public static Connection getConnection(){

Connection conn = null;
try{
conn=DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.106:1521:orcl", "system", "admin");
}catch(SQLException e){
System.out.println(e+"======out");
}

return conn;
}

public static Statement getStatment(Connection conn){
Statement stmt = null;
try {
stmt = conn.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
return stmt;
}

public static ResultSet getResultSet(Statement stmt){
ResultSet rs = null;
try {
rs = stmt.executeQuery("select * from t_user");
} catch (SQLException e) {
e.printStackTrace();
}
return rs;
}

public static void closeConn(Connection conn){
if(conn!=null){
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
conn=null;
}

public static void closeResultSet(ResultSet rs){
if(rs!=null){
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
rs=null;
}

public static void closePreparedStatement(PreparedStatement ps){
if(ps!=null){

try {
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
ps=null;
}
}
bolink5 2011-07-10
  • 打赏
  • 举报
回复
Statement ps = conn.createStatement();
你先确定下 conn对象是否为空
还有怎么没见LZ 加载数据库驱动啊
Fly_m 2011-07-10
  • 打赏
  • 举报
回复
报错原因?贴报错信息出来。
sudan_727923 2011-07-10
  • 打赏
  • 举报
回复
一点一点的调,要学会自己调
乎乎 2011-07-10
  • 打赏
  • 举报
回复
也不清楚是那一行出错。 看这些抛出的异常信息。只能确定是有对象为空。具体是那一个。你本人应该是最清楚的。
Zeus 2011-07-10
  • 打赏
  • 举报
回复
又有新错误了, org.apache.jasper.JasperException: java.lang.NullPointerException

81,095

社区成员

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

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