@@ -236,6 +236,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
236236
237237 override fun getString (columnIndex : Int ): String? {
238238 return when (val value = getColumnValue(columnIndex)) {
239+ is String -> value
239240 is Clob -> value.characterStream.use { it.readText() }
240241 else -> value?.toString()
241242 }
@@ -252,6 +253,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
252253
253254 override fun getByte (columnIndex : Int ): Byte {
254255 return when (val value = getColumnValue(columnIndex)) {
256+ is Byte -> value
255257 is Number -> value.toByte()
256258 is Boolean -> if (value) 1 else 0
257259 else -> value?.toString()?.toByte() ? : 0
@@ -260,6 +262,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
260262
261263 override fun getShort (columnIndex : Int ): Short {
262264 return when (val value = getColumnValue(columnIndex)) {
265+ is Short -> value
263266 is Number -> value.toShort()
264267 is Boolean -> if (value) 1 else 0
265268 else -> value?.toString()?.toShort() ? : 0
@@ -268,6 +271,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
268271
269272 override fun getInt (columnIndex : Int ): Int {
270273 return when (val value = getColumnValue(columnIndex)) {
274+ is Int -> value
271275 is Number -> value.toInt()
272276 is Boolean -> if (value) 1 else 0
273277 else -> value?.toString()?.toInt() ? : 0
@@ -276,6 +280,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
276280
277281 override fun getLong (columnIndex : Int ): Long {
278282 return when (val value = getColumnValue(columnIndex)) {
283+ is Long -> value
279284 is Number -> value.toLong()
280285 is Boolean -> if (value) 1 else 0
281286 else -> value?.toString()?.toLong() ? : 0
@@ -284,6 +289,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
284289
285290 override fun getFloat (columnIndex : Int ): Float {
286291 return when (val value = getColumnValue(columnIndex)) {
292+ is Float -> value
287293 is Number -> value.toFloat()
288294 is Boolean -> if (value) 1.0F else 0.0F
289295 else -> value?.toString()?.toFloat() ? : 0.0F
@@ -292,6 +298,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
292298
293299 override fun getDouble (columnIndex : Int ): Double {
294300 return when (val value = getColumnValue(columnIndex)) {
301+ is Double -> value
295302 is Number -> value.toDouble()
296303 is Boolean -> if (value) 1.0 else 0.0
297304 else -> value?.toString()?.toDouble() ? : 0.0
@@ -308,7 +315,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
308315 override fun getBytes (columnIndex : Int ): ByteArray? {
309316 return when (val value = getColumnValue(columnIndex)) {
310317 null -> null
311- is ByteArray -> value
318+ is ByteArray -> Arrays .copyOf( value, value.size)
312319 is Blob -> value.binaryStream.use { it.readBytes() }
313320 else -> throw SQLException (" Cannot convert ${value.javaClass.name} value to byte[]." )
314321 }
@@ -317,6 +324,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
317324 override fun getDate (columnIndex : Int ): Date ? {
318325 return when (val value = getColumnValue(columnIndex)) {
319326 null -> null
327+ is Date -> value.clone() as Date
320328 is java.util.Date -> Date (value.time)
321329 is Number -> Date (value.toLong())
322330 is String -> {
@@ -337,6 +345,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
337345 override fun getTime (columnIndex : Int ): Time ? {
338346 return when (val value = getColumnValue(columnIndex)) {
339347 null -> null
348+ is Time -> value.clone() as Time
340349 is java.util.Date -> Time (value.time)
341350 is Number -> Time (value.toLong())
342351 is String -> {
@@ -357,6 +366,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
357366 override fun getTimestamp (columnIndex : Int ): Timestamp ? {
358367 return when (val value = getColumnValue(columnIndex)) {
359368 null -> null
369+ is Timestamp -> value.clone() as Timestamp
360370 is java.util.Date -> Timestamp (value.time)
361371 is Number -> Timestamp (value.toLong())
362372 is String -> {
@@ -953,17 +963,17 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
953963 override fun getBlob (columnIndex : Int ): Blob ? {
954964 return when (val value = getColumnValue(columnIndex)) {
955965 null -> null
956- is ByteArray -> MemoryBlob (value)
957966 is Blob -> value
967+ is ByteArray -> MemoryBlob (value)
958968 else -> throw SQLException (" Cannot convert ${value.javaClass.name} value to Blob." )
959969 }
960970 }
961971
962972 override fun getClob (columnIndex : Int ): Clob ? {
963973 return when (val value = getColumnValue(columnIndex)) {
964974 null -> null
965- is String -> MemoryClob (value)
966975 is Clob -> value
976+ is String -> MemoryClob (value)
967977 else -> throw SQLException (" Cannot convert ${value.javaClass.name} value to Clob." )
968978 }
969979 }
0 commit comments