注册 登录
编程论坛 J2EE论坛

帮忙看看 谢谢了

elan1986 发布于 2008-11-15 15:49, 1415 次点击
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
    at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
    at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
    at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
    at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
    at com.lch.hibernate.Base.main(Base.java:25)
Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:812)
    at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3269)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1182)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2644)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:154)
    at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
    ... 5 more

这个是什么原因 是不是我的那个配置文档有问题?
我看了 但是还是没有找出来
大家帮忙看看 谢谢了
8 回复
#2
guoxhvip2008-11-15 17:30
好象是数据库连接失败 应该是hibernate.cfg.xml中配置的问题吧
#3
elan19862008-11-15 17:51
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql:///test</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">1</property>
        
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        
        <property name="hibernate.connection.password"></property>
        <property name="hibernate.hbm2ddl.auto">create</property>
        <mapping  resource="com/lch/hibernate/domain/User.hbm.xml"/>
    
    </session-factory>
</hibernate-configuration>


这个是我写的
帮忙看看 谢谢了
#4
huwangvs2008-11-15 19:08
<property name="hibernate.connection.url">jdbc:mysql:///test</property>
看看错了没。。。。。
#5
Ethip2008-11-15 19:09
在Hibernate中测试下,可能是MySQL的服务没有启动...没有对应的进程
#6
elan19862008-11-15 21:01
我更改了 还是不可以<property name="hibernate.connection.url">jdbc:mysql://localhost:3360/test</property>
我打包了 你帮忙看看吧

我在任务管理器里看到了MYSQL进程
并且我也打开mysql 查看了数据库

谢谢了
#7
guoxhvip2008-11-15 22:08
jdbc:mysql://localhost:3306/test
是端口是3306 不是3360
#8
elan19862008-11-17 16:48
问题已经解决
数据库连接没有问题
<property name="hibernate.connection.url">jdbc:mysql:///test</property>
这句没有错

错在是我

        <property name="hibernate.connection.password">1</property>
        
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        
        <property name="hibernate.connection.password"></property>
多写了<property name="hibernate.connection.password"></property>
没有提供密码
应该改为<property name="hibernate.connection.password">1</property>

谢谢大家了
#9
小乌龟2008-11-19 16:49
: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)

这个已经提示了
1