---------------------出现以下错误:log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Hibernate: select users0_.id as id, users0_.username as username0_, users0_.password as password0_ from zoutuo__users users0_
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at com.hibernate.dao.UsersDao.getAllInfo(UsersDao.java:23)
at com.hibernate.dao.UsersDao.main(UsersDao.java:36)
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'zoutuo.zoutuo__users' doesn't exist
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1026)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
... 7 more
Exception in thread "main" java.lang.NullPointerException
at com.hibernate.dao.UsersDao.main(UsersDao.java:37)---------------------hibernate.cfg.xml里的:<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration> <session-factory>
<property name="connection.username">root</property>
<property name="connection.url">jdbc:mysql://localhost:3306/zoutuo</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="myeclipse.connection.profile">Mysql</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">true</property>
<mapping resource="com/hibernate/vo/Users.hbm.xml" /> </session-factory></hibernate-configuration>---------------------hibernate.reveng.xml中的:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" ><hibernate-reverse-engineering>
<table name="users" catalog="zoutuo">
<primary-key>
<generator class="native"></generator>
</primary-key>
</table>
</hibernate-reverse-engineering>---------------------
我已经被这个问题困扰2天了,谁能救救我啊大哥大姐大虾小弟自学的MySQL,刚连接就出现这种错误,太无情了……

解决方案 »

  1.   

    对了,这是我调用查询的方法:
    package com.hibernate.dao;import java.util.List;import org.hibernate.Query;
    import org.hibernate.Session;
    import org.hibernate.Transaction;import com.hibernate.HibernateSessionFactory;public class UsersDao {
    Session session = null; Transaction tx = null; public List getAllInfo() {
    List list = null;
    try {
    session = HibernateSessionFactory.currentSession();
    tx = session.beginTransaction();
    String hql = "from Users";
    Query query = session.createQuery(hql);
    list = query.list();
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    if (session != null) {
    session.close();
    }
    }
    return list;
    } public static void main(String[] args) {
    UsersDao usersDao = new UsersDao();
    List list = usersDao.getAllInfo();
    System.out.println(list.size());
    }
    }