hibernate操作数据库 用hibernate操作mysql数据库,出现java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)异常,请问高手是什么原因,我的用户名和密码可以确保配置正确,而且root'@'localhost在mysql的manger链接测试也成功,为什么程序运行会程序上面异常?不要跟我说用户名和密码错误MySQL数据库异常 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是的,我在mysql的管理管理工具用相应的用户名和密码,连接测试成功,但是真正程序运行hibernate操作数据却出现上述异常,我的配置可以保证每配错用户名和密码,真不知是什么原因? //各位大神,我的hibernate配置如下<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="fileEncoding" value="utf-8" /> <property name="locations"> <list> <value>classpath*:db.properties</value> </list> </property> <property name="ignoreUnresolvablePlaceholders" value="true"></property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName"> <value>${jdbc.driverClassName}</value> </property> <property name="url"> <value>${jdbc.url}</value> </property> <property name="username"> <value>${jdbc.username}</value> </property> <property name="password"> <value>${jdbc.password}</value> </property> <property name="defaultAutoCommit"> <value>${jdbc.defaultAutoCommit}</value> </property> <property name="maxActive"> <value>${jdbc.maxActive}</value> </property> </bean> <!-- 开启Spring Required annotation --> <bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor" /> <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" /> <bean id="jdbcTemplate " class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource"> <ref bean="dataSource" /> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan" value="net.spring.**.entity" /> <property name="hibernateProperties"> <value> hibernate.dialect=org.hibernate.dialect.MySQLDialect <!-- hibernate.hbm2ddl.auto=update --> hibernate.show_sql=true hibernate.format_sql=false hibernate.connection.username=sh_test hibernate.connection.password=1234 </value> </property> </bean>//===================数据库properties==============================================#configuration JDBC Connectionjdbc.driverClassName=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://localhost:3306/webqq?useUnicode=true&characterEncoding=UTF-8jdbc.username=sh_testjdbc.password=1234jdbc.defaultAutoCommit=falsejdbc.maxActive=5jdbc.dialect=org.hibernate.dialect.MySQLDialect Access denied 一般看你使用的用户有没有赋予连接权限,或者连接有没有配置正确 我的用户名和密码都是正确的,权限也给了啊,为什么直接用底层的jdbc可以访问,用hibernate框架就不可以了? 问个SQL表里字段增加符号问题的问题 oracle 10g下载和安装 toad版本是7.3 ,所连接的数据库是oracle10g,打开toad中的表,里面的表不是按自动排序? 审计 为什么未选定行 oracle 文件操作问题,急!!!! 备分数据到备用库的表空间问题,多谢了。 check_box的问题 关于oracle dmp的问题请教 oracle 定时触发 请问启动oem还要配置什么东西。 hibernate 问题 求大神解决。 oracle如何查询表中blob类型数据,blob存储的是字符串,并且长度大于2000
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="fileEncoding" value="utf-8" />
<property name="locations">
<list>
<value>classpath*:db.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"></property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="defaultAutoCommit">
<value>${jdbc.defaultAutoCommit}</value>
</property>
<property name="maxActive">
<value>${jdbc.maxActive}</value>
</property>
</bean>
<!-- 开启Spring Required annotation -->
<bean
class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor" />
<bean
class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" /> <bean id="jdbcTemplate " class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="net.spring.**.entity" />
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
<!-- hibernate.hbm2ddl.auto=update -->
hibernate.show_sql=true
hibernate.format_sql=false
hibernate.connection.username=sh_test
hibernate.connection.password=1234
</value>
</property>
</bean>//===================数据库properties==============================================
#configuration JDBC Connection
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/webqq?useUnicode=true&characterEncoding=UTF-8
jdbc.username=sh_test
jdbc.password=1234
jdbc.defaultAutoCommit=false
jdbc.maxActive=5
jdbc.dialect=org.hibernate.dialect.MySQLDialect