`
wrong1111
  • 浏览: 248423 次
  • 性别: 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

    执行SQL报错:The used SELECT statements have a different number of columns 以上翻译:使用的SELECT语句具有不同数量的列 原因:我们在 SQL 语句中使用了 UNION 连接两张表时,查询字段数量不一致导致 # 效果...

    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$ ... 命令和参数之间必需用空格隔...

    微软内部资料-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 ...

    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 ...

    HANA SQLStatements ALL

    SAP HANA SQL Statements All for all kinds of reports.

    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...

    Thinking in Java 4th Edition

    Simpler print statements ..... 63 Using Java operators ........... 64 Precedence ........................... 64 Assignment .......................... 65 Aliasing during method calls ....... 66 ...

    python programming

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

    SSD7 选择题。Multiple-Choice

    (b) placing SQL keywords, such as select, under the column names they want to retrieve (c) typing a syntactically correct SQL query that uses column and table names similar to the correct column and...

    IDL英文原版(很好的一份IDL教材)

    3.5 Simple IDL statements......................................22 3.6 Getting information........................................25 3.7 Variables..............................................26 3.8 ...

    org.eclipse.jdt.core_3.5.2.v_981_R35x

    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners....

Global site tag (gtag.js) - Google Analytics