我的jsp为:
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="rate.*" %>
<%
//if (request.getParameter("ratepolicyid")!=null&&request.getParameter("ratepolicyname")!=null) {
try{
RatePolicyBean ratePolicyBean=new RatePolicyBean();
ratePolicyBean.addRatePolicy(java.lang.Integer.parseInt("8"),"fgdfgzhw");
}catch(Exception e){
e.toString();
}
// System.out.println(request.getParameter("ratepolicyid"));
//System.out.println(request.getParameter("ratepolicyname"));
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.setHeader("Location",request.getContextPath()+"/rate/RatePolicy.jsp");
//System.out.println("OKKKKK");
//}
%>
我调试用的class为:
package rate;
/**
* <p>Title: rate</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class test {
public test() {
}
public static void main(String[] args) {
test test1 = new test();
// /*
try{
RatePolicyBean ratePolicyBean= new RatePolicyBean();
ratePolicyBean.addRatePolicy(java.lang.Integer.parseInt("8"),"fgdfgzhw");
}catch(Exception e){
e.printStackTrace();
System.out.println("error");
}
System.out.println("OK");
//*/
//System.out.println("OK");
}
}
两个都运行
则class的数据库已插入
而jsp的无任何的提示,数据库中也没有结果!!!
我用的方法为:
public void addRatePolicy(int rateId,String rateName){
try{
Connection conn = ConnectionPool.getWeblogicConnection();
PreparedStatement pstmt=conn.prepareStatement("select RATE_ID from RATE_POLICY where RATE_ID="+rateId);
ResultSet rs=pstmt.executeQuery();
System.out.println("select RATE_ID from RATE_POLICY where RATE_ID=rateId");
String Strsql;
if (rs.next()){
Strsql="update RATE_POLICY set RATE_POLICY.RATE_NAME=? where RATE_ID=?";
pstmt=conn.prepareStatement(Strsql);
pstmt.setString(1,rateName);
pstmt.setInt(2,rateId);
pstmt.execute();
System.out.println("update RATE_POLICY set RATE_POLICY.RATE_NAME=? where RATE_ID=?");
}else
{
Strsql="insert into RATE_POLICY values (?,?)";
pstmt=conn.prepareStatement(Strsql);
pstmt.setInt(1,rateId);
pstmt.setString(2,rateName);
pstmt.execute();
System.out.println("insert into RATE_POLICY values (?,?)");
}
请大家帮我看看为什么(本人水平真的有限)!!!