1
1
package org .lowcoder .sdk .plugin .common .sql ;
2
2
3
+ import org .apache .commons .codec .binary .Base64 ;
3
4
import org .jetbrains .annotations .Nullable ;
4
5
6
+ import java .sql .Blob ;
5
7
import java .sql .ResultSet ;
6
8
import java .sql .ResultSetMetaData ;
7
9
import java .sql .SQLException ;
@@ -25,6 +27,7 @@ public class ResultSetParser {
25
27
public static final String DATETIME_COLUMN_TYPE_NAME = "datetime" ;
26
28
public static final String TIMESTAMP_COLUMN_TYPE_NAME = "timestamp" ;
27
29
public static final String YEAR_COLUMN_TYPE_NAME = "year" ;
30
+ public static final String BLOB_COLUMN_TYPE_NAME = "blob" ;
28
31
29
32
public static List <Map <String , Object >> parseRows (ResultSet resultSet ) throws SQLException {
30
33
ResultSetMetaData metaData = resultSet .getMetaData ();
@@ -74,6 +77,12 @@ private static Object getValue(ResultSet resultSet, int i, String typeName) thro
74
77
if (YEAR_COLUMN_TYPE_NAME .equalsIgnoreCase (typeName )) {
75
78
return resultSet .getDate (i ).toLocalDate ().getYear ();
76
79
}
80
+ if (BLOB_COLUMN_TYPE_NAME .equalsIgnoreCase (typeName )) {
81
+ //Convert binary data into base64
82
+ Blob blob = resultSet .getBlob (i );
83
+ byte [] blobBytes = blob .getBytes (1 , (int ) blob .length ());
84
+ return Map .of ("type" , "BLOB" , "length" , blobBytes .length , "content" , Base64 .encodeBase64String (blobBytes ));
85
+ }
77
86
return resultSet .getObject (i );
78
87
}
79
88
0 commit comments