Workaround in UCanAccess for multi-value fields: “incompatible data type in conversion: from SQL type OTHER”?

点点圈 提交于 2019-12-02 02:42:18

This is the first question about it I have ever seen. You can see an example of the complex types usage with UCanAccess in the ucanaccess web site, tab "Getting Started" (at the end of the page). Here's a junit test case: https://sourceforge.net/p/ucanaccess/code/HEAD/tree/ucanaccess/trunk/src/test/java/net/ucanaccess/test/ComplexTest.java (see the testComplex method).

In particular you can't call rslt.getString(2) but have to use rslt.getObject(2) . You'll get a ucanaccess wrapper of your data. If you wanted to get string that described the data content you can use rslt.getObject(2).toString(). The wrapping classes are:

net.ucanaccess.complex.Attachment,
net.ucanaccess.complex.SingleValue,
net.ucanaccess.complex.Version.

In your example, rslt.getObject(2) should return an array of net.ucanaccess.complex.SingleValue. Then you can call the method singleValue.getValue() on each array element to get the wrapped value.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!