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

前端 未结 1 1182
再見小時候
再見小時候 2021-01-22 02:55

I am trying to use UCanAccess to query a MS Access .accdb file. Everything works great, except when I query multi-value fields. For example those that have entries in the Row

1条回答
  •  [愿得一人]
    2021-01-22 03:26

    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.

    0 讨论(0)
提交回复
热议问题