From e3c9b4d049a57cba17b165d48222ebd07751b43c Mon Sep 17 00:00:00 2001 From: ecoolper Date: Sun, 14 Apr 2024 19:25:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9StatementUtil.setParam?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3oracle=E6=95=B0=E6=8D=AE=E5=BA=93set?= =?UTF-8?q?Object(inputStream)=E6=89=A7=E8=A1=8C=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8Cjava.sql.SQLException:=20=E6=97=A0?= =?UTF-8?q?=E6=95=88=E7=9A=84=E5=88=97=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/hutool/db/StatementUtil.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hutool-db/src/main/java/cn/hutool/db/StatementUtil.java b/hutool-db/src/main/java/cn/hutool/db/StatementUtil.java index 27552bce5..9a2079741 100644 --- a/hutool-db/src/main/java/cn/hutool/db/StatementUtil.java +++ b/hutool-db/src/main/java/cn/hutool/db/StatementUtil.java @@ -13,16 +13,10 @@ import cn.hutool.db.sql.SqlBuilder; import cn.hutool.db.sql.SqlLog; import cn.hutool.db.sql.SqlUtil; +import java.io.InputStream; import java.math.BigDecimal; import java.math.BigInteger; -import java.sql.CallableStatement; -import java.sql.Connection; -import java.sql.ParameterMetaData; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Types; +import java.sql.*; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -380,6 +374,18 @@ public class StatementUtil { // 忽略其它数字类型,按照默认类型传入 } + //InputStream,解决oracle情况下setObject(inputStream)报错问题,java.sql.SQLException: 无效的列类型 + if(param instanceof InputStream){ + ps.setBinaryStream(paramIndex, (InputStream) param); + return; + } + + //java.sql.Blob + if(param instanceof Blob){ + ps.setBlob(paramIndex, (Blob) param); + } + + // 其它参数类型 ps.setObject(paramIndex, param); }