`
wrong1111
  • 浏览: 253356 次
  • 性别: Icon_minigender_1
  • 来自: 湖南
社区版块
存档分类
最新评论

Select statements cannot be executed as an update.

阅读更多

初学IBATIS时,出现的错误。

 

异常:

 

java.sql.SQLException: Select statements cannot be executed as an update.
 at com.ibatis.sqlmap.engine.mapping.statement.SelectStatement.executeUpdate(SelectStatement.java:31)
 at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:447)
 at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
 at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:59)
 at com.ecp.ibatis.main.Test.addPerson(Test.java:46)
 at com.ecp.ibatis.main.Test.main(Test.java:60)
Exception in thread "main" 

 

 

person_SqlMap.xml

  

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Person">
    <resultMap id="person" class="com.ecp.ibatis.java.Person">
        <!--
        WARNING - This element is automatically generated by Abator for iBATIS, do not modify.
        This element was generated on Fri Mar 20 15:38:16 CST 2009.
        -->
        <result column="PER_ID" property="perId" jdbcType="NUMERIC"/>
        <result column="PER_FIRSTNAME" property="perFirstname" jdbcType="VARCHAR"/>
        <result column="PER_LASTNAME" property="perLastname" jdbcType="VARCHAR"/>
        <result column="PER_BIRTHDAY" property="perBirthday" jdbcType="TIMESTAMP"/>
        <result column="PER_WEIGTH_KG" property="perWeigthKg" jdbcType="NUMERIC"/>
        <result column="PER_HEIGHT_M" property="perHeightM" jdbcType="NUMERIC"/> 
    </resultMap>
    
	
    <select id="getPerson" resultMap="person" parameterClass="java.lang.Integer">
        <!--
        WARNING - This element is automatically generated by Abator for iBATIS, do not modify.
        This element was generated on Fri Mar 20 15:38:16 CST 2009.
        -->
        select PER_ID, PER_FIRSTNAME, PER_LASTNAME, PER_BIRTHDAY, PER_WEIGTH_KG, PER_HEIGHT_M
        from Person
        where PER_ID = #perId:NUMERIC#
    </select>
	<select id="addPerson"  resultClass="java.lang.Integer" parameterClass="com.ecp.ibatis.java.Person">
        insert into Person values(#perId,#perFirstname,#perLastname,#perBirthday,#perWeigthKg,#perHeightM)
    </select>
</sqlMap>

 

原因:

 

  是因为在xml文件中,配置的文件有误码,我所要做的操作是往数据库中插入一条记录。

 却在配置中配置 <select>

 

因此产生此错误.

 

 解决办法。把select 改成 insert.

 

分享到:
评论

相关推荐

    jscodetosequnce_js_

    JavaScript StatementsA JavaScript program is a list of statements to be executed by a computer.The value of z is 11.

    Sql for mysql

    5.12 The Null Value as an Expression . . . . . . . . . . . . . . . . . . . . . . 114 5.13 The Compound Scalar Expression . . . . . . . . . . . . . . . . . . . . 115 5.14 The Aggregation Function and ...

    MySQL:The used SELECT statements have a different number of columns

    在MySQL数据库操作中,"The used SELECT statements have a different number of columns" 是一个常见的错误提示,这表明在使用UNION或UNION ALL等合并查询语句时,参与合并的各个SELECT子句返回的列数量不匹配。...

    Delphi7.1 Update

    * A TLargeIntField cannot be used as a linking field in a master/detail relationship. Doing so results in the error &quot;Cannot access field &lt;fieldname&gt; as type variant.&quot; * TClientDataSet doesn...

    Intro to ABAP-----一套挺有意思的abap教材

    05. Retrieving Data with Select Statements 06. Control Statements 7. Data Structures and Creating Internal Tables 7a. Processing Internal Tables&gt; 08. Online Debugging 09. Modularization ...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 ...telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss ... 各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ ... 命令和参数之间必需用空格隔...

    ERROR 1222 (21000): The used SELECT statements have a different number of columns

    在MySQL数据库中,当你尝试执行一个包含`UNION`操作的SQL查询时,可能会遇到错误“ERROR 1222 (21000): The used SELECT statements have a different number of columns”。这个错误提示意味着你在`UNION`操作中...

    微软内部资料-SQL性能优化3

    To make use of either more or less strict isolation levels in applications, locking can be customized for an entire session by setting the isolation level of the session with the SET TRANSACTION ...

    PowerCommands for Visual Studio 2008

    It can be executed from different places depending on the type of project. For CSharp projects it can be executed from the references node. For Visual Basic and Website projects it can be executed ...

    hibernate c3p0 数据库连接池参数详解.txt

    &lt;property name="hibernate.c3p0.max_statements"&gt;50 ``` - **作用**:限制每个连接上缓存的 PreparedStatement 的最大数量。这有助于减少内存消耗。 ##### 3.6 hibernate.c3p0.idle_test_period - **含义**:...

    MySql存储过程编程.chm

    Using SELECT Statements with an INTO Clause Section 5.3. Creating and Using Cursors Section 5.4. Using Unbounded SELECT Statements Section 5.5. Performing Dynamic SQL with Prepared Statements ...

    TRI TPG 语法

    Analog Test Statements..................................................................................... 16 Digital Testing ............................................................................

    Cplusplus.Language.Tutorial.For.Beginner.Learn.Cplusplus.in.7.days

    C++ (pronounced see plus plus) was developed by Bjarne Stroustrup at Bell Labs as an extension to C, starting in 1979. C++ adds many new features to the C language, and is perhaps best thought of as a...

    Build-SQL-Tables.rar_empty

    This program expects to find a file with the name SQLStatements.txt in ... will create tables in the technical_library Access that should initially be empty, and already registered as an ODBC .

    require-statements:生成器需要`package.json`中的语句

    安装$ npm install --save require-statements用法var requireStatements = require ( 'require-statements' ) ;requireStatements ( ) ; // ^ Would read `./package.json` and return require statements for ...

    MyBatis User Guide.rar

    Exploring Mapped SQL Statements . 7 A Note about Namespaces........... 8 Scope and Lifecycle .......... 9 Mapper Configuration XML 10 properties ........ 11 settings ............ 12 typeAliases...

    python programming

    4.4 Output as String Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 4.4.1 Converting Numbers to Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 ...

    mybatisMapped报错 Statements collection does not contain value for

    ### mybatisMapped报错 Statements collection does not contain value for 在使用MyBatis框架进行数据库操作时,可能会遇到“Mapped Statements collection does not contain value for”这样的错误提示。这通常...

Global site tag (gtag.js) - Google Analytics