问题描述
程序架构ssh,数据库是sybase服务端字符集是iso_1hibernate3,struts2,spring3,sybase12.5.3问题描述:一个页面中有多个ajax的请求(strtuts的action),在执行的过程中,出现下述错误(但数据能正常返回)16:11:01,578DEBUGConnectionManager:374-performingcleanup16:11:01,578DEBUGConnectionManager:435-releasingJDBCconnection[(openPreparedStatements:0,globally:0)(openResultSets:0,globally:0)]16:11:01,593DEBUGJDBCExceptionReporter:40-SQLWarningjava.sql.SQLWarning:Charactersetconversionisnotavailablebetweenclientcharacterset'cp936'andservercharacterset'iso_1'.hibernate的连接字符串中设置了charset=cp936&language=us_english&jconnect_version=5,而数据库的服务端字符集是iso_1。之所以在hibernate的连接串中设成cp936是为了解决取数据中文乱码的问题。如果页面中是单个的ajax请求,就是执行单个的action,不会报上述的字符集转换错误,程序运行正常。如果连接串中设置iso_1,程序也运行正常,但从数据库取出来的中文数据都乱码。现在就是不清楚到底是sybase的问题,还是hibernate或者spring的配置哪里有问题。调了快一天了,请各位帮帮分析一下。页面中的ajax的两个请求(无论单独运行哪个请求都无问题)1.url:'organ.action',2.url:'user.action'applicationContent.xml<?xmlversion="1.0"encoding="UTF-8"?><!--<!DOCTYPEbeansPUBLIC"-//SPRING//DTDBEAN//EN""http://www.springframework.org/dtd/spring-beans.dtd"><beansdefault-autowire="byName">--><!--<!DOCTYPEbeansPUBLIC"-//SPRING//DTDBEAN2.0//EN""http://www.springframework.org/dtd/spring-beans-2.0.dtd"><beans>--><!--schema--><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><!--<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsd">--><!--数据库链接定义--><beanid="propertyConfigure"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><propertyname="locations"><list><value>classpath*:jdbc.properties</value></list></property></bean><beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource"><!--<beanid="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource">--><propertyname="driverClassName"value="${jdbc.driverClassName}"></property><propertyname="url"value="${jdbc.url}"></property><propertyname="username"value="${jdbc.username}"></property><propertyname="password"value="${jdbc.password}"></property><propertyname="maxActive"value="200"></property><propertyname="maxIdle"value="50"></property><propertyname="maxWait"value="60000"></property><propertyname="removeAbandoned"value="true"></property><propertyname="removeAbandonedTimeout"value="30"></property></bean><!--<beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource"><propertyname="driverClassName"value="com.mysql.jdbc.Driver"></property><propertyname="url"value="jdbc:mysql://localhost:3306/xlink"></property><propertyname="username"value="root"></property><propertyname="password"value="123456"></property>--><!--<propertyname="driverClassName"value="com.sybase.jdbc3.jdbc.SybDataSource"></property><propertyname="url"value="jdbc:sybase:Tds:192.168.1.50:5000/xlink?charset=cp936"></property><propertyname="username"value="sa"></property><propertyname="password"value="jonetech"></property><propertyname="maxActive"value="200"></property><propertyname="maxIdle"value="50"></property><propertyname="maxWait"value="60000"></property><propertyname="removeAbandoned"value="true"></property><propertyname="removeAbandonedTimeout"value="30"></property></bean>--><beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><propertyname="dataSource"ref="dataSource"/><propertyname="mappingResources"><list><value>com/shinee/monitor/model/JyUser.hbm.xml</value><value>com/shinee/monitor/model/JyOrgan.hbm.xml</value><value>com/shinee/monitor/model/JySvrplan.hbm.xml</value><value>com/shinee/monitor/model/JyBatchparastd.hbm.xml</value></list></property><propertyname="hibernateProperties"><props><propkey="hibernate.dialect">org.hibernate.dialect.Sybase11Dialect</prop><propkey="hibernate.show_sql">true</prop><!--<propkey="hibernate.c3p0.pool_size">2</prop><propkey="hibernate.connection.autocommit">false</prop><propkey="hibernate.connection.release_mode">after_statement</prop><propkey="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>--></props></property><!--另外一种写法--><!--<propertyname="dataSource">--><!--<refbean="dataSource"/></property>--></bean><beanid="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><propertyname="sessionFactory"><refbean="sessionFactory"/></property></bean><!--HibernateTemplate定义--><beanid="hibernateTemplate"class="org.springframework.orm.hibernate3.HibernateTemplate"><propertyname="sessionFactory"><refbean="sessionFactory"/></property></bean><beanid="baseTransactionProxy"abstract="true"class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"><propertyname="transactionManager"><refbean="transactionManager"/></property><propertyname="transactionAttributes"><props><propkey="save*">PROPAGATION_REQUIRED</prop><propkey="update*">PROPAGATION_REQUIRED</prop><propkey="find*">PROPAGATION_REQUIRED</prop><propkey="remove*">PROPAGATION_REQUIRED</prop><propkey="add*">PROPAGATION_REQUIRED</prop><propkey="*">PROPAGATION_REQUIRED</prop></props></property></bean><!--系统业务逻辑--><!--Dao部分--><beanid="userDao"class="com.shinee.monitor.dao.impl.UserDaoImpl"><propertyname="hibernateTemplate"><refbean="hibernateTemplate"></ref></property></bean><beanid="organDao"class="com.shinee.monitor.dao.impl.OrganDaoImpl"><propertyname="hibernateTemplate"><refbean="hibernateTemplate"></ref></property></bean><beanid="svrplanDao"class="com.shinee.monitor.dao.impl.SvrplanDaoImpl"><propertyname="hibernateTemplate"><refbean="hibernateTemplate"></ref></property></bean><beanid="batchparastdDao"class="com.shinee.monitor.dao.impl.BatchparastdDaoImpl"><propertyname="hibernateTemplate"><refbean="hibernateTemplate"></ref></property></bean><!--Service部分--><beanid="userService"parent="baseTransactionProxy"><propertyname="target"><beanclass="com.shinee.monitor.service.impl.UserServiceImpl"lazy-init="true"><propertyname="userDao"><reflocal="userDao"/></property></bean></property></bean><beanid="organService"parent="baseTransactionProxy"><propertyname="target"><beanclass="com.shinee.monitor.service.impl.OrganServiceImpl"><propertyname="organDao"><reflocal="organDao"/></property></bean></property></bean><beanid="svrplanService"parent="baseTransactionProxy"><propertyname="target"><beanclass="com.shinee.monitor.service.impl.SvrplanServiceImpl"><propertyname="svrplanDao"><reflocal="svrplanDao"/></property></bean></property></bean><beanid="batchparastdService"parent="baseTransactionProxy"><propertyname="target"><beanclass="com.shinee.monitor.service.impl.BatchparastdServiceImpl"><propertyname="batchparastdDao"><reflocal="batchparastdDao"/></property></bean></property></bean><!--Action部分--><beanid="loginAction"class="com.shinee.monitor.action.LoginAction"scope="prototype"><propertyname="userService"><reflocal="userService"></ref></property></bean><beanid="mainPageAction"class="com.shinee.monitor.action.MainPageAction"scope="prototype"></bean><beanid="logoutAction"class="com.shinee.monitor.action.LogoutAction"scope="prototype"></bean><beanid="userAction"class="com.shinee.monitor.action.sysconfig.UserAction"scope="prototype"><propertyname="userService"><reflocal="userService"></ref></property></bean><beanid="typetoString"class="com.shinee.monitor.util.Typetostring"scope="prototype"/><beanid="organAction"class="com.shinee.monitor.action.sysconfig.OrganAction"scope="prototype"><propertyname="organService"><reflocal="organService"></ref></property><propertyname="typetoString"><reflocal="typetoString"></ref></property></bean></bean></beans>