Topic: getHibernateTemplate().save(forum);save后数据库中出现乱码

  Print this page

1.getHibernateTemplate().save(forum);save后数据库中出现乱码 Copy to clipboard
Posted by: guorui_wh
Posted on: 2004-11-18 17:46

我跟踪过了,在getHibernateTemplate().save(forum);之前System.out.println
出来的是正确的,但是到数据库中以后就出现乱码,数据库是mysql4,驱动是mm驱动
顺便问一句,在spring ide里面
输入jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK会出现校验不能通过的错误,要我把&换成;号

2.Re:getHibernateTemplate().save(forum);save后数据库中出现乱码 [Re: guorui_wh] Copy to clipboard
Posted by: yakuu
Posted on: 2004-11-19 00:58

jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK

3.Re:getHibernateTemplate().save(forum);save后数据库中出现乱码 [Re: guorui_wh] Copy to clipboard
Posted by: guorui_wh
Posted on: 2004-11-19 11:05

还是不行阿,反而说url出错了

2004-11-19 11:09:29,941 WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null
2004-11-19 11:09:29,956 ERROR net.sf.hibernate.util.JDBCExceptionReporter - Cannot create JDBC driver of class 'org.gjt.mm.mysql.Driver' for connect URL '
        jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK
      '
2004-11-19 11:09:29,956 WARN net.sf.hibernate.cfg.SettingsFactory - Could not obtain connection metadata
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.gjt.mm.mysql.Driver' for connect URL '
        jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK
      ', cause:
java.sql.SQLException: No suitable driver
  at java.sql.DriverManager.getDriver(DriverManager.java:243)
  at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:743)
  at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:518)
  at org.springframework.orm.hibernate.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:59)
  at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
  at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1132)
  at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:766)
  at org.springframework.orm.hibernate.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:467)
  at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:405)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1057)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:287)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:954)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:889)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:827)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:662)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:270)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:954)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:889)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:827)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:662)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:270)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
  at com.bbs.service.imp.ForumServiceImpTest.setUp(ForumServiceImpTest.java:28)
  at junit.framework.TestCase.runBare(TestCase.java:125)
  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 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Cannot create JDBC driver of class 'org.gjt.mm.mysql.Driver' for connect URL '
        jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK
      '
java.sql.SQLException: No suitable driver
  at java.sql.DriverManager.getDriver(DriverManager.java:243)
  at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:743)
  at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:518)
  at org.springframework.orm.hibernate.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:59)
  at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
  at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1132)
  at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:766)
  at org.springframework.orm.hibernate.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:467)
  at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:405)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1057)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:287)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:954)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:889)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:827)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:662)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:270)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:954)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:889)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:827)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:662)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:270)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
  at com.bbs.service.imp.ForumServiceImpTest.setUp(ForumServiceImpTest.java:28)
  at junit.framework.TestCase.runBare(TestCase.java:125)
  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 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Cannot create JDBC driver of class 'org.gjt.mm.mysql.Driver' for connect URL '
        jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK
      '
java.sql.SQLException: No suitable driver
  at java.sql.DriverManager.getDriver(DriverManager.java:243)
  at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:743)
  at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:518)
  at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:173)
  at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:152)
  at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:128)
  at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:93)
  at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:209)
  at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:115)
  at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:96)
  at org.springframework.orm.hibernate.SessionFactoryUtils.newJdbcExceptionTranslator(SessionFactoryUtils.java:122)
  at org.springframework.orm.hibernate.HibernateAccessor.getJdbcExceptionTranslator(HibernateAccessor.java:158)
  at org.springframework.orm.hibernate.HibernateAccessor.afterPropertiesSet(HibernateAccessor.java:201)
  at org.springframework.orm.hibernate.HibernateTemplate.<init>(HibernateTemplate.java:115)
  at org.springframework.orm.hibernate.support.HibernateDaoSupport.createHibernateTemplate(HibernateDaoSupport.java:87)
  at org.springframework.orm.hibernate.support.HibernateDaoSupport.setSessionFactory(HibernateDaoSupport.java:74)
  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:324)
  at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:684)
  at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:588)
  at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:720)
  at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:747)
  at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:736)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:844)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:662)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:270)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:954)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:889)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFa2004-11-19 11:09:31,081 WARN org.springframework.jdbc.support.SQLErrorCodesFactory - Error while getting database metadata
org.springframework.jdbc.support.MetaDataAccessException: Error while getting connection; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.gjt.mm.mysql.Driver' for connect URL '
        jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK
      '
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.gjt.mm.mysql.Driver' for connect URL '
        jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK
      '
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.gjt.mm.mysql.Driver' for connect URL '
        jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK
      ', cause:
java.sql.SQLException: No suitable driver
  at java.sql.DriverManager.getDriver(DriverManager.java:243)
  at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:743)
  at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:518)
  at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:173)
  at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:152)
  at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:128)
  at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:93)
  at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:209)
  at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:115)
  at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:96)
  at org.springframework.orm.hibernate.SessionFactoryUtils.newJdbcExceptionTranslator(SessionFactoryUtils.java:122)
  at org.springframework.orm.hibernate.HibernateAccessor.getJdbcExceptionTranslator(HibernateAccessor.java:158)
  at org.springframework.orm.hibernate.HibernateAccessor.afterPropertiesSet(HibernateAccessor.java:201)
  at org.springframework.orm.hibernate.HibernateTemplate.<init>(HibernateTemplate.java:115)
  at org.springframework.orm.hibernate.support.HibernateDaoSupport.createHibernateTemplate(HibernateDaoSupport.java:87)
  at org.springframework.orm.hibernate.support.HibernateDaoSupport.setSessionFactory(HibernateDaoSupport.java:74)
  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:324)
  at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:684)
  at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:588)
  at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:720)
  at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:747)
  at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:736)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:844)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:662)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:270)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:954)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:889)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:827)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:662)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:270)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:954)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:889)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:827)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:662)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:270)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
  at com.bbs.service.imp.ForumServiceImpTest.setUp(ForumServiceImpTest.java:28)
  at junit.framework.TestCase.runBare(TestCase.java:125)
  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 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
2004-11-19 11:09:31,347 WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null
2004-11-19 11:09:31,347 ERROR net.sf.hibernate.util.JDBCExceptionReporter - Cannot create JDBC driver of class 'org.gjt.mm.mysql.Driver' for connect URL '
        jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK
      '
2004-11-19 11:09:31,347 WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null
2004-11-19 11:09:31,347 ERROR net.sf.hibernate.util.JDBCExceptionReporter - Cannot create JDBC driver of class 'org.gjt.mm.mysql.Driver' for connect URL '
        jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK
      '
2004-11-19 11:09:31,347 ERROR net.sf.hibernate.util.JDBCExceptionReporter - Cannot open connection
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.gjt.mm.mysql.Driver' for connect URL '
        jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK
      ', cause:
java.sql.SQLException: No suitable driver
  at java.sql.DriverManager.getDriver(DriverManager.java:243)
  at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:743)
  at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:518)
  at org.springframework.orm.hibernate.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:59)
  at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
  at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3297)
  at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3277)
  at org.springframework.orm.hibernate.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:379)
  at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:269)
  at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:201)
  at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:49)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
  at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
  at $Proxy0.doCreateForum(Unknown Source)
  at com.bbs.service.imp.ForumServiceImpTest.testDoCreateForum(ForumServiceImpTest.java:72)
  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:324)
  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 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)

4.Re:getHibernateTemplate().save(forum);save后数据库中出现乱码 [Re: guorui_wh] Copy to clipboard
Posted by: guorui_wh
Posted on: 2004-11-19 11:16

问题解决了

我format之后变成这样子,就报错
<value>
jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK
</value>

换成这样子就好了
<value>jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK</value>Smile

5.Re:getHibernateTemplate().save(forum);save后数据库中出现乱码 [Re: guorui_wh] Copy to clipboard
Posted by: wzj616
Posted on: 2004-11-23 22:02

<value>jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK</value>
能行吗?
大哥,在xml配置文件里面Spring的dtd会认为是个无效的标记的。
第二楼写的才是正确的


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923