未找到在 Oracle 数据库上运行的 Java 方法

标签 java oracle plsql

我无法处理在 Oracle 服务器上执行我的 Java 方法。我使用 loadjava 将我的 java 类加载到数据库中,并使用此查询创建函数:

create or replace function getPeriodIdDay (multiplicity number, stardDate date, endDate date) return number
as language java
name 'Period.getPeriodIdDay(int, oracle.sql.Date, oracle.sql.Date) return int';

我在类里面的方法是:

  public static int getPeriodIdDay(int multiplicity, DATE startDate, DATE date){
       // day period calculation
       int dayPeriodId =  (date.dateValue().getTime() - startDate.dateValue().getTime()) / MILLIS_IN_DAY;
       return dayPeriodId / multiplicity;
   }

每次尝试执行这个函数时我都会得到这个错误:

29531. 00000 -  "no method %s in class %s"
*Cause:    An attempt was made to execute a non-existent method in a
           Java class.
*Action:   Adjust the call or create the specified method.

我做错了什么?

最佳答案

你的函数声明中java方法的签名是:

Period.getPeriodIdDay(int, oracle.sql.Date, oracle.sql.Date) return int

但 java 类本身中方法的签名是:

int getPeriodIdDay(int multiplicity, DATE startDate, DATE date)

如果在此处复制 DATE 的大写没有错误,那么这是不同的类型。

即使是复制错误:检查 java 类的导入是否使用了相同的 Date 类。

关于未找到在 Oracle 数据库上运行的 Java 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41589203/

相关文章:

java - 是-XX :+UseG1GC the correct replacement for -Xincgc?

java - 这个 HQL 有什么问题? "No data type for node"

sql - ORA-22905 - 使用 select 语句查询表类型时

sql - 如何在 PL/SQL 中编写 FOR EACH 循环?

plsql - 如何从正确的 PLSQL 读取字符串

java - 一旦设置了 spring mvc 样板项目,python/RoR 的开发速度会更快吗?

java - 使用另一个数组中的字符串元素创建数组名称

java - Spring Boot schema.sql,使用PL/SQL初始化数据库

oracle - 如何使用 SQLcl 和 SQLPlus 连接到 Oracle 数据库,但没有 TNSNames.ORA 文件?

oracle - INSERT ALL 带条件 PL/SQL