精华内容
下载资源
问答
  • Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型 ### The error may exist in UserMapper.xml ### The...

    一、现象描述

    今天在开发过程中遇到一个问题就是使用MyBatis插入数据时,死活插不进去。数据都有传递啊,为啥啊?碰到这些问题总有点懵逼,具体报错信息如下:

    org.apache.ibatis.exceptions.PersistenceException: 
    ### Error updating database.  Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #3 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型
    ### The error may exist in UserMapper.xml
    ### The error may involve com.queen.mybatis.mapper.UserMapper.addUserMap-Inline
    ### The error occurred while setting parameters
    ### SQL: insert into   t_user(id,loginId,userName,role,note)   values(?,?,?,?,?)
    ### Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #3 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型
    	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
    	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:154)
    	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:141)
    	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:51)
    	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
    	at com.sun.proxy.$Proxy2.addUserMap(Unknown Source)
    	at com.queen.mybatis.MyBatisTest.testAdd(MyBatisTest.java:41)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:606)
    	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
    Caused by: org.apache.ibatis.type.TypeException: Error setting null for parameter #3 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型
    	at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:45)
    	at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:81)
    	at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:80)
    	at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:61)
    	at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:74)
    	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:47)
    	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:105)
    	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:71)
    	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:152)
    	... 28 more
    Caused by: java.sql.SQLException: 无效的列类型
    	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
    	at oracle.jdbc.driver.OracleStatement.getInternalType(OracleStatement.java:3424)
    	at oracle.jdbc.driver.OraclePreparedStatement.setNullCritical(OraclePreparedStatement.java:4197)
    	at oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:4186)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:606)
    	at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:70)
    	at com.sun.proxy.$Proxy4.setNull(Unknown Source)
    	at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:43)
    	... 36 more

    二、解决办法

    经过网络的几番搜查,终于发现MyBatis 插入空值时,需要指定JdbcType ,否则会报错。

    没有修改之前的XML文件,我的note这个字段在传递的时候是没有指定传值的,如下:

    <insert id="addUserMap" parameterType="java.util.Map">
    	<selectKey keyProperty="id" order="BEFORE" resultType="Integer">
    		select SEQ_T_USER_ID.nextval from dual
    	</selectKey>
    	insert into
    	t_user(
    		id,
    		loginId,
    		userName,
    		role,
    		note)
    	values(
    		#{id},
    		#{loginId},
    		#{userName},
    		#{role},
    		#{note}
    	)
    </insert>

    修改之后如下:

    <insert id="addUserMap" parameterType="java.util.Map">
    	<selectKey keyProperty="id" order="BEFORE" resultType="Integer">
    		select SEQ_T_USER_ID.nextval from dual
    	</selectKey>
    	insert into
    	t_user(
    		id,
    		loginId,
    		userName,
    		role,
    		note)
    	values(
    		#{id},
    		#{loginId,jdbcType=VARCHAR},
    		#{userName,jdbcType=VARCHAR},
    		#{role,jdbcType=VARCHAR},
    		#{note,jdbcType=VARCHAR}
    	)
    </insert>

     

    这个时候运行正常了。 

     

    希望这个问题,对大家都有所帮助。本来也是一件很小的差别。一句话:都怪自己太年轻。

     

     

                                                          1563721777457161.png

    展开全文
  • 报错:Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. 原因:jsp页面未向controller传入参数,或者参数名字不一致。 修改:传入相同名字的参数,或...

    报错:Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property.

    原因:jsp页面未向controller传入参数,或者参数名字不一致。

    修改:传入相同名字的参数,或使用@RequestParam设置id即可。
    public xxx xxx(@RequestParam(name = “id”,required = true) String MyId)
    其中:注解中的name值为页面传入参数名。

    展开全文
  • Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111 ; uncategorized SQLException for SQL []; ...

    mybatis执行update语句:

    <update id="updateBatchId" parameterType="java.util.HashMap">
            update TABLE1
               set BATCHID = #{batch_id}           
               where BUSINESS_NO = #{commit_id,jdbcType=VARCHAR}          
        </update>

    报错:

    Error setting null for parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111
    ; uncategorized SQLException for SQL []; SQL state [99999]; error code [17004]; 无效的列类型: 1111; nested exception is java.sql.SQLException: 无效的列类型: 1111

    找原因发现batch_id与dao层传入的名称不一致,应为batchid

    修改为:

    <update id="updateBatchId" parameterType="java.util.HashMap">
            update TABLE1
               set BATCHID = #{batchid}           
               where BUSINESS_NO = #{commit_id,jdbcType=VARCHAR}          
        </update>

     

    执行正常。

    展开全文
  • Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.postgresql.util.PSQLException: This statement has been closed. at org.mybatis.spring....

    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='year', mode=IN, javaType=class java.lang.Integer, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.postgresql.util.PSQLException: This statement has been closed. at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77) ~[mybatis-spring-1.3.1.jar!/:1.3.1] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) ~[mybatis-spring-1.3.1.jar!

     

    mapper.xml文件里的方法:

    <if test="year!= null">
              AND year= #{year}
    </if>

     

    对查询变量增加jdbcType参数,指定参数类型

    <if test="year!= null">
              AND year= #{year, jdbcType=INTEGER}
    </if>
    展开全文
  • Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111 at org.apache.ibatis.scripting.defaults....
  • 报错原因:1.参数传的不对(参数名对不上); 2.参数类型不匹配; 解决办法:1....2.在xml中,参数后面加jdbcType=VARCHAR eg:#{id,jdbcType=VARCHAR} 3.去pojo类去检查自己的属性名和页面传递的参数名是否匹配,注意...
  • 报错内容: Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #10 with JdbcType... Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configu...
  • Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型 at org.mybatis.spring.MyBatisExceptionTranslator...
  • Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (4 > number of parameters, which is 3). ...
  • 流利说 Level 3 全文

    万次阅读 多人点赞 2019-05-22 10:51:17
    Lesson 6 Setting the Bill     Level 3 Unit1 1/4 Listening Lesson 1 An Unusual Day Kathy usually gets up at 6:30, but this morning, she didn’t hear her alarm. ...
  • Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (4 > number of parameters, which is 3). 最后...
  • mybatis+oracle 插入或者批量插入值为null的时候报这个错误 Error setting null for parameter #4 with JdbcType OTHER 或者java.sql.SQLException: 无效的列类型: 1111 解决方法在值为null的字段上指定jdbcType...
  • Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111 运行时发现以上异常,首先想到是不是哪个...
  • Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0). 刚开始...
  • 向数据库添加值为null时 报错-------报错信息:org.apache.ibatis.type.TypeException: Error setting null for parameter #8 ... Try setting a different JdbcType for this parameter or a different jdbcType...
  • Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0). ``` ...
  • 因为mysql比较灵活,现在springboot项目中集成数据库几乎都是采用mysql,由于公司项目需要,任然采用oralce数据库, 在开发时遇到下面问题。 Cause: org.apache.ibatis.type.TypeException: ... Try setting a di...
  • Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).
  • Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).   ...
  • Try setting a different JdbcType for this parameter or a different configuration property. 原因 报错显示update SQL生成时,类属性值为null,没有字段属性类型 方案 @TableField(value = "yaw_wdd",jdbcType =...
  • Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: 无效的列索引 遇到个奇怪的问题,mybatis在赋值时给10个问号赋予11个值导致的报错。...
  • 激光雷达学习笔记(一)数据采集

    万次阅读 多人点赞 2013-02-20 23:13:33
    // Baud rate setting return com_changeBaudrate(baudrate); } static void com_disconnect(void) { if (HCom != INVALID_HANDLE_VALUE) { CloseHandle(HCom); HCom = INVALID_HANDLE_VALUE; } } static ...
  • mybatis执行时报错内容如下: Error setting null for parameter #2 with ... Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sq
  • Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0). 一直...
  • org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error selecting key or setting result to parameter object. Cause: org.apache.ibatis.type.T....
  • mybatis报 Error setting null for parameter #10 with JdbcType OTHER . mybatis 插入空值時需要指定jdbcType 报错内容: Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #10 ...
  • org.springframework.jdbc.UncategorizedSQLException: Error setting null for parameter #1 with JdbcType ... Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configu...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 27,960
精华内容 11,184
关键字:

adifferentsettingtry