Androidpn-server 数据库使用HSQL,偶尔会发生异常,异常原因为记录序列有时为空,今天动手迁移至mysql,对hibernate不了解,需要修改驱动配置文件jdbc.properties和hibernate.cfg.xml配置文件,中途遇到两个问题:
"Host 'localhost' is not allowed to connect to this MySQL server"
Mysql拒绝远程访问,修正方法为将IP地址修改为localhost;
第二个问题,就是:
Unknown table ‘system_sequences’ in information_schema错误
通过baidu查到(http://blog.sina.com.cn/s/blog_4ea0151a0100nbvv.html)
字面意思应该是hibernate不知道的schema里system_sequences表,于是检查hibernate配置文hibernate.cfg.xml
发现dialect方言用错了,忘记改过来 org.hibernate.dialect.HSQLDialect
我用的是mysql5,应该用这个 org.hibernate.dialect.MySQL5Dialect
修改后不再报Unknown table ‘system_sequences’ in information_schema错误了。
hibernate所有的方言类都放在org.hibernate.dialect包中,从hibernate3.jar中可以找到这些类。
他们均是 org.hibernate.dialect.Dialect 的子类,
修改完成,不知道还会不会报错。