Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将数据从jsp插入oracle不会';行不通_Oracle_Jsp_Tomcat_Plsql - Fatal编程技术网

将数据从jsp插入oracle不会';行不通

将数据从jsp插入oracle不会';行不通,oracle,jsp,tomcat,plsql,Oracle,Jsp,Tomcat,Plsql,我正在尝试构建一个与oracle连接的web应用程序。 我编写了一个jsp文件代码来将数据插入数据库,但它不起作用。 我想使用callableStatement和我在下面写的PL/SQL过程 CREATE OR REPLACE PROCEDURE applyInsert04(cid IN VARCHAR2, cidno IN NUMBER,sid IN VARCHAR2,aid IN VARCHAR2, weeknum IN VARCHAR2,pstatus IN VARCHAR2 ,ispro

我正在尝试构建一个与oracle连接的web应用程序。 我编写了一个jsp文件代码来将数据插入数据库,但它不起作用。 我想使用callableStatement和我在下面写的PL/SQL过程

CREATE OR REPLACE PROCEDURE applyInsert04(cid IN VARCHAR2, cidno IN NUMBER,sid IN VARCHAR2,aid IN VARCHAR2, weeknum IN VARCHAR2,pstatus IN VARCHAR2 ,isprocessed IN VARCHAR2, result OUT VARCHAR2)

IS
nCnt NUMBER;
BEGIN
result:='';

 INSERT INTO processed(c_id , c_id_no, s_id,a_id,week_num,p_status,is_processed) values(cid , cidno, sid, aid,weeknum,pstatus,isprocessed);
COMMIT;
result:='done';

END;
/
这是jsp文件

<%@ page language="java" contentType="text/html; charset=utf-8"pageEncoding="utf-8"%>
    <%@ page import="java.sql.*" %>
< !DOCTYPE html>
<html>
<head><title></title></head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String s_id = (String) session.getAttribute("user");
String c_id = request.getParameter("c_id");
int c_id_no = 3;
String week_num = request.getParameter("week_num");
String p_status = request.getParameter("p_status");
String is_processed="unprocessed ";
String a_id="01";


Connection myConn = null;
String result = null;
String dburl = "someurl";
String user = "user"; 
String passwd = "pass";
String dbdriver = "oracle.jdbc.driver.OracleDriver";

try {
    Class.forName(dbdriver);
    myConn = DriverManager.getConnection(dburl, user, passwd);
} catch (SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
}

CallableStatement cstmt = myConn.prepareCall("{call applyInsert04(?, ?, ?, ?, ?, ?, ?, ?)}");
cstmt.setString(1,c_id);
cstmt.setInt(2,c_id_no);
cstmt.setString(3,s_id);
cstmt.setString(4,a_id);
cstmt.setString(5,week_num);
cstmt.setString(6,p_status);
cstmt.setString(7,is_processed);
cstmt.registerOutParameter(8, java.sql.Types.VARCHAR);

System.out.println(c_id+ "," + c_id_no + "," + s_id + "," + a_id +","+ week_num +","+ p_status +","+ is_processed +","+ java.sql.Types.VARCHAR);
try {

    cstmt.execute();
    result = cstmt.getString(8);
    System.out.println(result);
 %>

<script>    
alert("<%=result%> ");
location.href = "apply_project.jsp";
</script>
<%
   } catch (SQLException ex) {
        System.err.println("SQLException: " + ex.getMessage());
    } finally {
        if (cstmt != null)
        try {
               myConn.commit();
               cstmt.close();
               myConn.close();
        } catch (SQLException ex) {

        }
    }
    %>

< !DOCTYPE html>
警报(“”);
location.href=“apply_project.jsp”;

如果我做错了什么,请帮助我

你以前已经问过了:或者这是一个新问题?我非常想解决这个问题,但我做不到..至少放
ex.printStackTrace()到最后一个
catch
块中-否则您不知道
myConn.commit()中是否有错误。顺便说一句,这样的代码不属于JSP,了解模式,将代码放到servlet中,使用JSP只显示结果。谢谢!我会尝试了解更多关于它的信息你以前已经问过了:或者这是一个新问题吗?我非常想解决这个问题,但我做不到..至少放
ex.printStackTrace()到最后一个
catch
块中-否则您不知道
myConn.commit()中是否有错误。顺便说一句,这样的代码不属于JSP,了解模式,将代码放到servlet中,使用JSP只显示结果。谢谢!我会尽量多了解一些