From 4f437acf63e81bf9b80e9082b861bb140d806daf Mon Sep 17 00:00:00 2001 From: Christopher Ramey Date: Thu, 23 Aug 2012 23:34:50 +0000 Subject: [PATCH] Added (basic) support for clob. Slightly improved debugging information. --- src/com/binarythought/jdbcjson/JDBCJSON.java | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/com/binarythought/jdbcjson/JDBCJSON.java b/src/com/binarythought/jdbcjson/JDBCJSON.java index 5072a7e..a5e6a65 100644 --- a/src/com/binarythought/jdbcjson/JDBCJSON.java +++ b/src/com/binarythought/jdbcjson/JDBCJSON.java @@ -2,6 +2,7 @@ package com.binarythought.jdbcjson; import java.io.FileInputStream; import java.io.FileWriter; +import java.sql.Clob; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; @@ -197,12 +198,30 @@ public class JDBCJSON } break; + case Types.CLOB: + Clob clob = rs.getClob(i); + if(clob == null){ + if(column == null){ writer.name(rsmd.getColumnName(i)); } + writer.nullValue(); + } else if(clob.length() <= Integer.MAX_VALUE){ + if(column == null){ writer.name(rsmd.getColumnName(i)); } + writer.value(clob.getSubString(1, (int)clob.length())); + } else if(debug){ + warnings.add( + "CLOB column " + + (column == null ? rsmd.getColumnName(i) : column) + + " too big" + ); + } + break; + default: if(debug){ warnings.add( "Unsupported column, " + (column == null ? rsmd.getColumnName(i) : column) + - ", type " + rsmd.getColumnTypeName(i) + ", type " + rsmd.getColumnTypeName(i) + " [" + + rsmd.getColumnType(i) + "]" ); } break;