简体   繁体   English

JDBC-从JAVA调用PLSQL会给出Java.sql.SQLException:ORA-06550

[英]JDBC - Calling PLSQL from JAVA gives Java.sql.SQLException: ORA-06550

I'm in a huge trouble with my call to a PLSQL from Java. 我从Java调用PLSQL遇到了很大的麻烦。 Here's my code: 这是我的代码:

static final String PLSQL = "{call DBK_PDG_METADATI_CEDOLINO.dbp_main(?,?,?,?,?,?,?,?,?)}";

Connection conn = DataSourceUtils.getConnection(jdbcTemplate.getDataSource());
CallableStatement cs = conn.prepareCall(PLSQL);

    for (Cedolino item : items) {
        LOG.info("################# ELABORAZIONE CEDOLINO " + item.getTestata().getAnagrafica().getCodFiscaleAmministrato() + " #################");
        cedolini.getCedolino().add(item);
        setParametersForPlSql(cs, item);

        try{
            cs.execute();
        }catch(SQLException e){
            LOG.info(e.toString());
        }

    }

cs.close();
conn.close();

private void setParametersForPlSql(CallableStatement cs, Cedolino ced){

    try {
        cs.setInt("tipo_lancio", 1);
        cs.setString("iscr", ced.getTestata().getTrattamento().getIscrizione().trim());
        cs.setString("rts", ced.getTestata().getDpt().trim());
        cs.setString("codfisc", ced.getTestata().getAnagrafica().getCodFiscaleAmministrato().trim());
        cs.setString("lingua", this.lingua);
        cs.setString("file_name", null);
        cs.setString("dir_spec", null);
        cs.setString("stato_elab", "S");
        cs.setString("descr_elab", null);


    } catch (SQLException e) {
        e.printStackTrace();
    }

}

This code works good except for cs.execute , that gives me this error 这段代码除了cs.execute之外效果很好,这给了我这个错误

java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'DBP_MAIN'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

I checked a thousand times, parameters and types and numbers match perfectly. 我检查了一千遍,参数,类型和数字是否完全匹配。 DB connection is also good, because I do some caching first and it works. 数据库连接也很好,因为我先进行了一些缓存,然后工作了。

Already tried to delete DBK_PDG_METADATI_CEDOLINO but nothing it is needed. 已经尝试删除DBK_PDG_METADATI_CEDOLINO但是不需要任何操作。 Can you help me to figure out it? 你能帮我弄清楚吗?

  1. Problem could be related to the JDBC driver which may not support Named Parameters. 问题可能与可能不支持命名参数的JDBC驱动程序有关。

Try to check it first like: 尝试先检查它,例如:

  Connection myConn = . . .   // connection to the RDBMS for Database
  DatabaseMetaData dbmd = myConn.getMetaData();
  if (dbmd.supportsNamedParameters() == true)
  {
      System.out.println("NAMED PARAMETERS FOR CALLABLE"
                        + "STATEMENTS IS SUPPORTED");
  }

and if it is not - use parameter indexes to set instead of names... 如果不是,请使用参数索引而不是名称进行设置...

  1. Is there any OUT or INOUT parameters in that Stored Procedure? 该存储过程中是否有任何OUT或INOUT参数?

If so, you need to register those parameters using registerOutParameter of the CallableStatement and give a placeholder for output. 如果是这样,你需要注册使用这些参数registerOutParameter中的CallableStatement ,并给予输出的占位符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.sql.SQLException:ORA-06550 - java.sql.SQLException: ORA-06550 java.sql.SQLException: ORA-06550: 从 java 代码调用过程后 - java.sql.SQLException: ORA-06550: after calling procedure from java code Java语言-java.sql.SQLException:ORA-06550 - Java Language - java.sql.SQLException: ORA-06550 java.sql.SQLException:ORA-06550:第1行第13列:授予用户对EXECUTE包的权限后 - java.sql.SQLException: ORA-06550: line 1, column 13: After granting user permission to EXECUTE package 永久性 ORA-06550 错误,使用 jdbc 从 java 应用程序调用存储的 function - Permanent ORA-06550 error, calling stored function from java application using jdbc 引起:java.sql.SQLException:ORA-06550:第 1 行,第 7 列:PLS-00306:ZDBC11CAA5BDA99F77E6FB4DABD_SPE_FA 7 调用中的 ZDBC11CAA5BDA99F77E6FB4DABD8SPE_7 的错误编号或类型 - Caused by: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'PR_SP_FAHMI' Accesing remote postgres from Windows gives java.sql.SQLException: No suitable driver found for jdbc:postgresql - Accesing remote postgres from Windows gives java.sql.SQLException: No suitable driver found for jdbc:postgresql java.sql.SQLException:ORA-00904 - java.sql.SQLException: ORA-00904 java.sql.SQLException:ORA-01747 - java.sql.SQLException: ORA-01747 Java.sql.SQLException:ORA-00604 - Java.sql.SQLException: ORA-00604
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM