How to use setClob method in jdbc?

后端 未结 2 433
一整个雨季
一整个雨季 2021-01-26 11:49

I need to insert a large string as clob into a table. I am using setClob method of PreparedStatement. But the values are not getting inserted into the database table. Can anyone

相关标签:
2条回答
  • 2021-01-26 12:07

    What database are you inserting the value to? For example for Oracle back-end, preparedStatement methods have 4k limitation on CLOB.

    You could use:

    Clob clob = ...
    String chuck = clob.getSubString(1,10);
    clob.setString(1,chuck);
    

    To verify that the size is not the issue here.

    0 讨论(0)
  • 2021-01-26 12:13

    I had the same problem using WebLogic and Oracle. I found the solution in the doc: http://docs.oracle.com/cd/B19306_01/appdev.102/b14259/xdb11jav.htm under the section "Loading a Large XML Document into the Database with JDBC"

    The only problem I had with this was that the CLOB.createTemporary required an OracleConnection, but my connection object was of type $ProxyXX which I could not cast to OracleConnection without getting a ClassCastException. Solved it buy using conn.getMetaData().getConnection() that got me a T4CConnection which I could cast to OracleConnection.

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