gpt4 book ai didi

java - 异常: Inconsistent java and sql object types

转载 作者:行者123 更新时间:2023-12-02 12:01:30 26 4
gpt4 key购买 nike

有以下类型:

CREATE OR REPLACE TYPE my_type IS OBJECT (
id VARCHAR2(20),
name VARCHAR2(40),
phone NUMBER
);

我正在尝试使用这些类型创建对象:

....
Object[] myArray = new Object[3];
Object[] struct = new Object[values.size()];

int arrayIndex = 0;
for (User user : values) {
myArray[0] = user.id().toString();
myArray[1] = user.getName().toString();
myArray[2] = user.getPhone();

struct[arrayIndex++] = con.createStruct("my_type",myArray);
}

在con.createStruct创建结构体时,出现错误:

java.sql.SQLException: Inconsistent java and sql object types, for classes implementing ORAData or OracleData, respective factory classes ORADataFactory and OracleDataFactory should be registered in typeMap.

可能出了什么问题?

最佳答案

   myArray[0] = user.id().toString();
myArray[1] = user.getName().toString();
myArray[2] = user.getPhone();

这应该是这样的:

-- First element of the array.
myArray[0].id = user.id().toString();
myArray[0].name = user.getName().toString();
myArray[0].phone = user.getPhone();

关于java - 异常: Inconsistent java and sql object types,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47221796/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com