插入数据时出现了异常,检查了n遍FileVO和数据库的类型是一致的,名称也没错,求助。。
FileVO.java    get和set方法省略:
         private int fileId;
private int fileSize;
private int fileTypeId;
private String  path;
private String  fileName;
private String  timeLenth;
private String fitType;
private String upTime;
private String modifyTime;
private String linkFlag;file.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="fileSqlMap"><select id="getFileListByLinkFlag" parameterClass="fileVO" resultClass="fileVO">
            SELECT  file_id fileId,
  file_size fileSize,
  file_type_id fileTypeId,
  path path,
  file_name  fileName,
  time_lenth timeLenth,
  fit_type fitType,
  up_time upTime,
  modify_time modifyTime,
  link_flag linkFlag
   FROM   c_file
   WHERE  link_flag = #linkFlag#</select>
 
<insert id="addFile"  parameterClass="fileVO">
insert into c_file
(file_size,file_type_id,path,file_name,time_lenth,fit_type,up_time,modify_time,link_flag)
 values(#fileSize#,#fileTypeId#,#path#,#fileName#,#timeLenth#,#fitType#,now(),now(),#linkFlag#)</insert>
</sqlMap>
异常信息如下:
[INFO ] 2010-04-12 10:08:56 :Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
 [INFO ] 2010-04-12 10:08:56 :SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
 org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [S1009]; error code [0];   
--- The error occurred in com/hztx/map/file.xml.  
--- The error occurred while applying a parameter map.  
--- Check the fileSqlMap.addFile-InlineParameterMap.  
--- Check the statement (update failed).  
--- Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/hztx/map/file.xml.  
--- The error occurred while applying a parameter map.  
--- Check the fileSqlMap.addFile-InlineParameterMap.  
--- Check the statement (update failed).  
--- Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/hztx/map/file.xml.  
--- The error occurred while applying a parameter map.  
--- Check the fileSqlMap.addFile-InlineParameterMap.  
--- Check the statement (update failed).  
--- Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:447)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
at org.springframework.orm.ibatis.SqlMapClientTemplate$9.doInSqlMapClient(SqlMapClientTemplate.java:369)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:193)
at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:367)
at com.hztx.dao.impl.FileDAOImpl.addFile(FileDAOImpl.java:14)
at com.hztx.service.impl.FileServiceImpl.addFile(FileServiceImpl.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)

解决方案 »

  1.   

    Connection is read-only? oracle已指出错误了啊? 检查一下oracle用户是否有修改数据表数据的权限。
      

  2.   

    权限没问题,原来是我在spring的配置文件命名不匹配,
      <tx:advice id="txAdvice" transaction-manager="transactionManager" >
     <tx:attributes>  
    <tx:method name="insert*" propagation="REQUIRED" />
    <tx:method name="delete*" propagation="REQUIRED" />
    <tx:method name="update*" propagation="REQUIRED" />
    <tx:method name="*" read-only="true" />
            </tx:attributes>  
    </tx:advice>
    问题已解决,依然感谢。