Java 偏移量1处的函数或过程转义语法格式错误

Java 偏移量1处的函数或过程转义语法格式错误,java,database,eclipse,postgresql,stored-procedures,Java,Database,Eclipse,Postgresql,Stored Procedures,我在eclipse中执行了一段代码,我的目标是在postgres数据库中调用一个存储过程。我尝试使用从servlet传递的值,但出现以下错误: “偏移量1处的函数或过程转义语法格式错误。” 所以现在我尝试硬编码这些值。还是一样的问题。什么是补偿?请帮我解决这个错误。Iv已经检查了字段的顺序和数据类型。它们是正确的 public int dispCustomer3(Cust cc){ con=dbCon.getConnection(); //PreparedStatement p

我在eclipse中执行了一段代码,我的目标是在postgres数据库中调用一个存储过程。我尝试使用从servlet传递的值,但出现以下错误: “偏移量1处的函数或过程转义语法格式错误。”

所以现在我尝试硬编码这些值。还是一样的问题。什么是补偿?请帮我解决这个错误。Iv已经检查了字段的顺序和数据类型。它们是正确的

public int  dispCustomer3(Cust cc){
    con=dbCon.getConnection();
    //PreparedStatement ps3=null;
    System.out.println("inside update function ");
    CallableStatement callableStatement =null;
    try {
        callableStatement=con.prepareCall("{SELECT fn_UpdateCustomer(37, 'Test_Customer56','Test_Customer56','Requirement','Customer_Location',NULL,2,2,NULL,'Customer_Contact_Info','Account_Contact_Info','01-02-2016','01-04-2016',5,'Comments',1,2);}");
        /*callableStatement.setInt(1,cc.getCustId());
        callableStatement.setString(2,cc.getShortName());
        callableStatement.setString(3,cc.getStatus_name() );
        callableStatement.setString(4,cc.getRequirement());
        callableStatement.setString(5,cc.getCustomer_location());
        callableStatement.setInt(6,cc.getDemo_location_type_id());
        callableStatement.setInt(7, cc.getDeployment_type_id());
        callableStatement.setInt(8, cc.getRequested_by_id());
        callableStatement.setInt(9, cc.getPilot_resource_id());
        callableStatement.setString(10, cc.getCustomer_contact_info());
        callableStatement.setString(11, cc.getAccount_contact_info());
        callableStatement.setDate(12, cc.getDemo_planned_on());
        callableStatement.setDate(13, cc.getDemo_actual_on());
        callableStatement.setInt(14, cc.getStatus_id());
        callableStatement.setString(15, cc.getComments());*/
        callableStatement.registerOutParameter(1, java.sql.Types.INTEGER);
        callableStatement.executeUpdate();



    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }finally{dbCon.closeConnection(con);}
    return 1;



}
}

使用
CallableStatement
时,您应该
CALL
您的过程,而不是
SELECT
。比如:

callableStatement=con.prepareCall("{CALL fn_UpdateCustomer(37, 'Test_Customer56','Test_Customer56','Requirement','Customer_Location',NULL,2,2,NULL,'Customer_Contact_Info','Account_Contact_Info','01-02-2016','01-04-2016',5,'Comments',1,2)}");

您得到的错误,
偏移量1处格式错误的函数或过程转义语法
引用了
SELECT
关键字。

我做了更改。但现在我得到了:“偏移量203处的函数或过程转义语法格式错误”,这意味着您解决了当前的问题,并且在Connection.prepareCall()参数的字符#203处出现了一个新的转义语法。试着去掉“;”在争论的最后,看看这是否解决了你的问题。您可以通过每次检查报告的偏移量来调试代码。为了检查例如#203字符,您可以将代码复制粘贴到记事本++或升华文本2或任何其他半智能编辑器中!