how to Retrive the CLOB value from Oracle using java

后端 未结 2 1381
小蘑菇
小蘑菇 2020-12-07 01:34
SELECT DESCRIPTION,DETAILED_DESCRIPTION,PRIORITY,RISK_LEVE FROM Table_Name

The DETAILED_DESCRIPTION column is having value in CL

相关标签:
2条回答
  • 2020-12-07 02:34

    After retrieving your data, you can use the getClob () method to return your Clob. Then you needs to open the Clob's stream to read the data (Mayb be char or binary data).

    If the clob is known to be a plain string, you maybe also wish to use

    clob.getSubString(1, (int) clob.length());

    So try this

    Clob clob = resultSet.getClob("DETAILED_DESCRIPTION")
    record.add(clob.getSubString(1, (int) clob.length());
    

    see http://www.java2s.com/Code/JavaAPI/java.sql/ResultSetgetClobintcolumnIndex.htm

    0 讨论(0)
  • 2020-12-07 02:34

    This might help you,

        // Select LOB locator into standard result set.
    ResultSet rs =
       stmt.executeQuery ("SELECT blob_col, clob_col FROM lob_table");
    while (rs.next())
    {
       // Get LOB locators into Java wrapper classes.
       java.sql.Blob blob = rs.getBlob(1);
       java.sql.Clob clob = rs.getClob(2);
    
    }
    

    Refer to below link for more details, http://docs.oracle.com/cd/A84870_01/doc/java.816/a81354/oralob2.htm

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