连接mysql字符编码解决办法

<!--spring中的hibernate配置-->
<bean id="MySQLbean" class="org.apache.commons.dbcp.BasicDataSource">
	<property name="driverClassName" value="com.mysql.jdbc.Driver">
	</property>
	<property name="url" value="jdbc:mysql://localhosthost:3306/dbname?userUnicode=true&amp;characterEncoding=gb2312"/>	
	<property name="username" value="root"></property>
	<property name="password" value="pass"></property>
</bean>



<!--hibernate.cfg.xml字符编码配置-->
<session-factory>
	<property name="connection.username">root</property>
	<property name="connection.url">jdbc:mysql://localhost:3306/thdb	</property>
	<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
	<property name="connection.password">pass</property>
	<property name="connection.userUnicode">true</property>
	<property name="connection.characterEncoding">gb2312</property>
</session-factory>

你可能感兴趣的:(spring,mysql,Hibernate,xml,jdbc)