日期:2014-05-18  浏览次数:20679 次

谁能帮帮我-----Hibernate
第一个hibernate,连接数据库的时候老是出现异常,如下:
    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:82)
at   org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
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:301)
at   org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:110)
at   org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:137)
at   org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:49)
at   org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:24)
at   org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:271)
at   org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1079)
at   examples.Test.insertData(Test.java:27)
at   examples.Test.main(Test.java:8)
Caused   by:   java.sql.SQLException:   ERROR:     unrecognized   configuration   parameter   "xactisolevel "

at   org.postgresql.core.QueryExecutor.execute(Unknown   Source)
at   org.postgresql.Connection.ExecSQL(Unknown   Source)
at   org.postgresql.Connection.ExecSQL(Unknown   Source)
at   org.postgresql.Connection.getTransactionIsolation(Unknown   Source)
at   org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:115)
at   org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:298)
...   8   more

      我用的eclipse+myeclipse,myeclipse的数据源已经配置好了,连接也没问题,但就是在程序里出现错误!

------解决方案--------------------
Caused by: java.sql.SQLException: ERROR: unrecognized configuration parameter "xactisolevel "

xactisolevel 这是什么啊? 删除试下~~
------解决方案--------------------

Cannot open connection
打不开db连接,重新配置你的数据源;

如果不是上面的问题,那么就是你的映射有问题;