在春天用字符串保存blob对象

时间:2015-02-17 09:52:14

标签: java spring model-view-controller jdbc spring-jdbc

我的数据库中有blob数据列,而我的客户端都准备好写SP(存储过程)来更新并在表中插入数据。

我正在使用此函数在DB中存储或更新blob对象。

@Override
public String saveInvoicePdfBlob(String userId, String invoiceNo,String transactionNo, Blob pdfBlob) throws DataBaseException{
    String plSql = "\n";
    plSql += "declare" + "\n";
    plSql += "  resp varchar2(1000);" + "\n";
    plSql += "begin" + "\n";
    plSql += "resp := srv.payment."+AppConstants.SAVE_INVOICE_PDFURL+"('"+invoiceNo+"',"
            +"'"+transactionNo+"',"
            +""+pdfBlob+""
            +");"+ "\n";
    plSql += "  ? := resp;" + "\n";
    plSql += "end;" + "\n";
    logger.debug("saveInvoicePdfUrl SQL : {} ", plSql);
    String result = jdbcDAOSupport.execReqSql(
            dataSource, plSql);
    return result;
}

这是我在jdbcDAOSupportLayer中的execReqSql函数: -

public String execReqSql(final DataSource dataSource, final String sql) throws RegistrationException
{

    String result = "";
    Connection connection = null;
    CallableStatement cs = null;
    try
    {
        connection = dataSource.getConnection();
        cs = connection.prepareCall(sql);
        cs.registerOutParameter(1, Types.VARCHAR);
        cs.execute();
        result = cs.getString(1);
    }
    catch (SQLException sqle)
    {   
        log.debug("Error occured : {} ",sqle.getMessage());
        String errorMessage="The system is currently unavailable.";
        throw new RegistrationException(errorMessage);
    }
    catch (Exception e)
    {   
        log.debug("Error occured : {} ",e.getMessage());
        String errorMessage="The system is currently unavailable.";
        throw new RegistrationException(errorMessage);
    }
    finally
    {
        try
        {
            if (null != cs)
            {
                cs.close();
            }
        }
        catch (SQLException e)
        {
            String errorMessage="The system is currently unavailable.";
            log.debug("Error occured : {} ",e.getMessage());
            throw new RegistrationException(errorMessage);
        }
        catch (Exception e)
        {   
            String errorMessage="The system is currently unavailable.";
            log.debug("Error occured : {} ",e.getMessage());
            throw new RegistrationException(errorMessage);
        }
        try
        {
            if (null != connection)
            {
                connection.close();
            }
        }
        catch (SQLException e)
        {   
            String errorMessage="The system is currently unavailable.";
            log.debug("Error occured : {} ",e.getMessage());
            throw new RegistrationException(errorMessage);
        }
        catch (Exception e)
        {   
            String errorMessage="The system is currently unavailable.";
            throw new RegistrationException(errorMessage);
        }
    }
    return result;
}

但每当我调用此函数时,我都会遇到此异常: -

 Wrong number of types of arguments in call to function.
 ORA-06550:line 5,column 1;
 PL/SQL: Statement Ignored.

0 个答案:

没有答案