JSP+Oracle 10g,死活插不进记录了...不知道这是什么原因?

nocoo 2006-03-22 08:30:45
<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>阿</title>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<%
String no = request.getParameter("sno");
String name = request.getParameter("sname");
String isfree = request.getParameter("isfree");
String skills = request.getParameter("skills");
String wants = request.getParameter("wants");
String telnum = request.getParameter("telnum");
if (no.equals("") || name.equals("") || isfree.equals("") || skills.equals("") || wants.equals("") || telnum.equals("")) {
%>
<jsp:forward page="error.jsp"></jsp:forward>
<%
}
Connection conn = null;
Statement stmt = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:nocoo",
"jbuser",
"abc");
stmt = conn.createStatement();
stmt.executeUpdate("INSERT INTO SKILLS VALUES('" + no + "','" + name + "','" + isfree + "','" + skills + "','" + wants + "','" + telnum + "');");
stmt.close();
conn.close();
}
catch (SQLException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
//ok
%>
</body>
...全文
89 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dlxu 2006-03-22
  • 打赏
  • 举报
回复
肯定是没有Commit吧
nocoo 2006-03-22
  • 打赏
  • 举报
回复
可为什么同样的句子,拿出来就没问题了呢?
老鱼趣多多 2006-03-22
  • 打赏
  • 举报
回复
把SQL语句拿出来单独写,是个好习惯。
也不容易出错。
老鱼趣多多 2006-03-22
  • 打赏
  • 举报
回复
stmt = conn.createStatement();
String strSql = "INSERT INTO SKILLS VALUES('" + no + "','" + name + "','" + isfree + "','" + skills + "','" + wants + "','" + telnum + "')";
stmt.executeUpdate(strSql);
yyzh 2006-03-22
  • 打赏
  • 举报
回复
conn.commit();
nocoo 2006-03-22
  • 打赏
  • 举报
回复
效果是,没有异常,但是进数据库看没有插入记录。好郁闷啊...

81,092

社区成员

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

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