浏览 10780 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2006-08-31
eclipse 3.1,MS SQL 2000,windows 2000 配置文件: ibatis_config.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd"> <sqlMapConfig> <properties resource="conf/database.properties"/> <settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true" errorTracingEnabled="true" maxRequests="32" maxSessions="10" maxTransactions="5" useStatementNamespaces="false" /> <transactionManager type="JDBC"> <dataSource type="SIMPLE"> <property value="${driver}" name="JDBC.Driver"/> <property value="${url}" name="JDBC.ConnectionURL"/> <property value="${username}" name="JDBC.Username"/> <property value="${password}" name="JDBC.Password"/> <property value="${MaximumActiveConnections}" name="Pool.MaximumActiveConnections"/> <property value="${MaximumIdleConnections}" name="Pool.MaximumIdleConnections" /> <property value="${MaximumCheckoutTime}" name="Pool.MaximumCheckoutTime"/> <property value="${TimeToWait}" name="Pool.TimeToWait" /> <property value="${PingQuery}" name="Pool.PingQuery" /> <property value="${PingEnabled}" name="Pool.PingEnabled"/> <property value="${PingConnectionsOlderThan}" name="Pool.PingConnectionsOlderThan"/> <property value="${PingConnectionsNotUsedFor}" name="Pool.PingConnectionsNotUsedFor"/> </dataSource> </transactionManager> <sqlMap resource="conf/User.xml"/> </sqlMapConfig> database.properties #################################### # Database Connectivity Properties #################################### driver=com.microsoft.jdbc.sqlserver.SQLServerDriver url=jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=iBatis_Test;SelectMethod=Cursor username=sa password= ################## #Pool Properties ################## MaximumActiveConnections=10 MaximumIdleConnections=5 MaximumCheckoutTime=120000 TimeToWait=500 PingQuery=select 1 from t_user PingEnabled=false PingConnectionsOlderThan=1 PingConnectionsNotUsedFor=1 User.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="User"> <typeAlias alias="user" type="org.ibatis.dm.User"/> <select id="getUser" parameterClass="int" resultClass="user"> <![CDATA[ select name, sex from t_user where id = #id# ]]> </select> <update id="updateUser" parameterClass="user"> <![CDATA[ UPDATE t_user SET name=#name#, sex=#sex# WHERE id = #id# ]]> </update> <insert id="insertUser" parameterClass="user"> INSERT INTO t_user ( name, sex); VALUES ( #name#, #sex# ); </insert> <delete id="deleteUser" parameterClass="java.lang.String"> delete from t_user where id = #value# </delete> </sqlMap> 错误提示信息: com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in conf/User.xml. --- The error occurred while applying a parameter map. --- Check the updateUser-InlineParameterMap. --- Check the parameter mapping for the 'id' property. --- Cause: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The specified SQL type is not supported by this driver. Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The specified SQL type is not supported by this driver. at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:504) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90) at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.update(SqlMapClientImpl.java:68) at ibatis.dao.UserTestCase.testUpdateUser(UserTestCase.java:136) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The specified SQL type is not supported by this driver. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.validateSqlType(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.setObjectInternal(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.setNull(Unknown Source) at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:171) at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125) at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:76) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78) ... 19 more Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The specified SQL type is not supported by this driver. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.validateSqlType(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.setObjectInternal(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.setNull(Unknown Source) at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:171) at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125) at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:76) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:504) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90) at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.update(SqlMapClientImpl.java:68) at ibatis.dao.UserTestCase.testUpdateUser(UserTestCase.java:136) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The specified SQL type is not supported by this driver. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.validateSqlType(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.setObjectInternal(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.setNull(Unknown Source) at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:171) at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125) at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:76) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:504) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90) at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.update(SqlMapClientImpl.java:68) at ibatis.dao.UserTestCase.testUpdateUser(UserTestCase.java:136) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) 你的分析: 这是我的测试过程: public void testUpdateUser();{ try{ sqlMap.startTransaction();; User user = (User);sqlMap.queryForObject("getUser",new Integer(2););; assertNotNull(user);; user.setName("iBatis");; sqlMap.update("updateUser",user);; sqlMap.commitTransaction();; }catch(SQLException e);{ e.printStackTrace();; } finally{ try{ sqlMap.endTransaction();; }catch(SQLException e);{ e.printStackTrace();; } } } 在更新时(sqlMap.update("updateUser",user);) 就会抛出这个异常,有谁知道这个问题该如何解决? (google一下,只见提问,好像没见有人做出过正面回答!) 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2006-08-31
不要用ms官方的jdbc驱动,有很多问题的。建议使用jTds
http://jtds.sourceforge.net/ |
|
返回顶楼 | |
发表时间:2006-08-31
谢谢!明白了!
但问题出现了,总得有法解决吧,我用hibernate咋就不出错呢!(我就是见不得"异常"的人,莫怪!莫怪!) jTDS JDBC Driver先用用试试,谢过了! 这个问题先摆在这儿,知道的朋友说说啊? |
|
返回顶楼 | |
发表时间:2006-09-04
是不是你的SQLServer没升级到sp4啊
|
|
返回顶楼 | |
发表时间:2006-09-04
-- The error occurred while applying a parameter map.
--- Check the updateUser-InlineParameterMap. --- Check the parameter mapping for the 'id' property. |
|
返回顶楼 | |
发表时间:2006-09-04
zelsa 写道 不要用ms官方的jdbc驱动,有很多问题的。建议使用jTds
http://jtds.sourceforge.net/ 以前SQL Server 2000 时代M$自己出的JDBC Driver确实很难用,但是现在SQL Server 2005的推出已经改变了这个状态…… 大家可以尝试使用一下Microsoft SQL Server 2005 JDBC Driver 1.1,完全向下兼容其他SQL Server版本,速度和性能也有很大的改进。 下载地址:http://www.microsoft.com/downloads/details.aspx?FamilyId=6D483869-816A-44CB-9787-A866235EFC7C&displaylang=en |
|
返回顶楼 | |
发表时间:2006-09-04
Allen 写道 以前SQL Server 2000 时代M$自己出的JDBC Driver确实很难用,但是现在SQL Server 2005的推出已经改变了这个状态…… 大家可以尝试使用一下Microsoft SQL Server 2005 JDBC Driver 1.1,完全向下兼容其他SQL Server版本,速度和性能也有很大的改进。 下载地址:http://www.microsoft.com/downloads/details.aspx?FamilyId=6D483869-816A-44CB-9787-A866235EFC7C&displaylang=en Note The JDBC driver is designed to work on any operating system that supports the use of a Java Virtual Machine (JVM). However, only Sun Solaris, Red Hat Linux, and Windows 2000 or later operating systems are officially supported. 另外,不知道有没有相关的性能(或负载)测试,以前2000的JDBC很难应付高并发的应用,功能也不完善。 |
|
返回顶楼 | |
发表时间:2006-09-05
to IAmOK:我的机器上的SQL 2000已经升级到SP4,不过我现在改用了jTDS JDBC Driver,可以测试了;
Microsoft SQL Server 2005 JDBC Driver 1.1这东西以后再试试! 谢谢各位的帮忙! |
|
返回顶楼 | |
发表时间:2006-09-05
到SP3就不会有问题了。
|
|
返回顶楼 | |