Java插入mysql数据库出现了乱码 我学习hibernate,向数据库中插入数据的时候出现了乱码,我的配置都是正确的,就是如果插入中文就出现乱码。请各位指点! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 mysql的中文问题是老问题了吧,随便上网一搜就是一堆。你都做哪些配置了?贴出来看看 <hibernate-configuration> <session-factory> <property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">123456</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.show_sql">true</property> <mapping resource="com/ysj/hibernate/User.hbm.xml" /> </session-factory></hibernate-configuration> 是不是字符集问题?上网查下mysql这方面的设置吧,用mysql自己的客户端或是第三方客户端看下中文操作有不有问题先吧。 <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/hibernate?useUnicode=true&characterEncoding=GB2312 </property>这样表示你建的数据库采用中文编码 1、安装mysql时将语言设为gb23122、程序连库时<property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/hibernate?useUnicode=true&characterEncoding=GB2312 </property> 一般是你的mysql没有配好编码,注意mysql每一个表,每一个字段都要是gb2312的才行 1、安装mysql时将语言设为gb2312 2、程序连库时 <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/hibernate?useUnicode=true&characterEncoding=GB2312 </property> 经过这几个步骤基本就可以了。 每一个表的下面都有该表的属性中间有个选项选gb2312,utf8均可还有安装MySQL之前由此选项不是配置文件问题 用过 dataTable的 进 struts2迭代标签,不是一个对象,应该怎么迭代 jsp中能不能用fso 关于web打印的问题 BEA dev2dev WebLogic管理精华3 关于EL的一个问题,请求解答!给分 关闭连接库连接问题 简述如何通过串口采集数据 java备份mysql数据库问题,请各位高手帮忙!!! jb8中写了个绘图的applet(很多参数),jb中正常运行,离开JB运行不了,马上给分!! servlet是多线程怎么理解的 使用struct从哪里调用application?
你都做哪些配置了?贴出来看看
<session-factory>
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123456</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>
<mapping resource="com/ysj/hibernate/User.hbm.xml" />
</session-factory>
</hibernate-configuration>
<property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/hibernate?useUnicode=true&characterEncoding=GB2312 </property>
这样表示你建的数据库采用中文编码
2、程序连库时<property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/hibernate?useUnicode=true&characterEncoding=GB2312 </property>
2、程序连库时 <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/hibernate?useUnicode=true&characterEncoding=GB2312 </property> 经过这几个步骤基本就可以了。
中间有个选项选gb2312,utf8均可
还有安装MySQL之前由此选项
不是配置文件问题