Forum Discussion

Gepir's avatar
Gepir
Occasional Contributor
8 years ago

groovy blob read

Hi,   I;m trying to read blob from DB, I've created this script (below)    def blob = sql.firstRow("SELECT CASE.APPLICATIONS.DATAPACKAGE as blob FROM CASE.APPLICATIONS WHERE APPLICATIONS.STATUS =...
  • Gepir's avatar
    8 years ago

    So I've found the solution...

    import groovy.sql.Sql
    import java.sql.*
    
    sql = Sql.newInstance("jdbc:oracle:thin:@::", "", "")
    //selct blob
    java.sql.Blob blob = sql.firstRow("SELECT CASE.APPLICATIONS.DATAPACKAGE as blob FROM CASE.APPLICATIONS WHERE APPLICATIONS.STATUS = '0' And APPLICATIONS.APPLICATIONNAME Is Not Null ORDER BY APPLICATIONS.CREATED DESC").blob
    byte[] bdata = blob.getBytes(1, (int) blob.length());
    String text = new String(bdata);
    log.info text;

    next step is decrypt blob...