Wednesday, August 31, 2016

Convert Sql clob to string in java

    String query = "";
            ResultSet output = stmt.executeQuery(query);
            String clobStr ="";
            while(output.next()){
                StringBuffer strOut = new StringBuffer();
                String aux;
                try {
                    BufferedReader br = new BufferedReader(output.getClob("").
                            getCharacterStream());
                    while ((aux=br.readLine())!=null) {
                        strOut.append(aux);
                        strOut.append(System.getProperty("line.separator"));
                    }
                }catch (Exception e) {
                    e.printStackTrace();
                }
                clobStr = strOut.toString().replace(" ", "").trim();
            }

No comments:

Post a Comment