使用 huibernate 问题出现了啊 :2011-05-29 17:53:34 SQL Exception
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))以前都是可以 连接上的,重新安装了一次系统,就这样了啊 
我的mysql 数据库的 用户名 root ,密码是 brig,
但是 这句报错是  (using password: YES)),不知道是怎么设置的 ,
我的 hibernate.cfg.xml 文件内容如下:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
<property name="myeclipse.connection.profile">liming</property>
<property name="connection.url">jdbc:mysql://127.0.0.1:3306/liming</property>
<property name="connection.username">root</property>
<property name="connection.password">brig</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping resource="com/sterning/books/model/Books.hbm.xml" />
<mapping resource="com/sterning/books/model/Customers.hbm.xml" />
</session-factory>
</hibernate-configuration>不知道哪里出了问题 ,请高手指点下

解决方案 »

  1.   

    数据库连接就没有建立上,看看mysql授权了没有,如果没有,在mysql中用grant授权
      

  2.   

    2011-05-29 17:53:34 SQL Exception
    org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))以前都是可以 连接上的,重新安装了一次系统,就这样了啊  
    我的mysql 数据库的 用户名 root ,密码是 brig,
    但是 这句报错是 (using password: YES)),不知道是怎么设置的 ,
    我的 hibernate.cfg.xml 文件内容如下:
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
    <session-factory>
    <property name="show_sql">true</property>
    <property name="myeclipse.connection.profile">liming</property>
    <property name="connection.url">jdbc:mysql://127.0.0.1:3306/liming</property>
    <property name="connection.username">root</property>
    <property name="connection.password">brig</property>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="dialect">www.cctv40.cnorg.hibernate.dialect.MySQLDialect</property>
    <mapping resource="com/sterning/books/model/Books.hbm.xml" />
    <mapping resource="com/sterning/books/model/Customers.hbm.xml" />
    </session-factory>
    </hibernate-configuration>
    看的好模糊啊。
      

  3.   

    你配置文件中的密码写的是YES吗?明明是brig
      

  4.   

    创建 PoolableConnectionFactory  出错, 估计是你的用户名  和密码不正确!
      

  5.   

    可是我测试过 数据库是可以连接上的 ,不知道怎么 运行工程时有连接不上了。
    package com.sterning.bean;import org.hibernate.HibernateException;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.Configuration; //The archive: /bookAdmin1/WebRoot/WEB-INF/lib/antlr-2.7.2.jar 
    public class Test { public static void main(String[] args) {
    try {
    SessionFactory sf = new Configuration().configure()
    .buildSessionFactory();
    Session session = sf.openSession();
    Transaction tx = session.beginTransaction(); Books pd = new Books();
    pd.setBookId(11);
    pd.setBookName("教父");
    pd.setBookAuthor("Godfather");
    pd.setBookPublish("1");
    pd.setBookIsbn("DVD");
    session.save(pd); int bookId = 3;
    Books BooksIn = null;
    BooksIn = (Books) session.get(Books.class, bookId);
                if (BooksIn==null)
                {
         System.out.println("BooksIn is null");
                }
                else
                {
         System.out.println(BooksIn.getBookName());            
                }
    tx.commit();
    session.close();
    System.out.println("sdfsdf");
    } catch (HibernateException e) {
    e.printStackTrace();
    }