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

hibernate配置c3p0的问题
我在hibernate中配置c3p0的   xml   如下:
<?xml   version= '1.0 '   encoding= 'utf-8 '?>
<!DOCTYPE   hibernate-configuration
        PUBLIC   "-//Hibernate/Hibernate   Configuration   DTD//EN "
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd ">
<hibernate-configuration>
<session-factory>
<property   name= "connection.driver_class "> net.sourceforge.jtds.jdbc.Driver </property>
<property   name= "connection.url "> jdbc:jtds:sqlserver://localhost:1433/login </property>

<property   name= "connection.password "> sa </property>
<property   name= "connection.username "> sa </property>

<property   name= "hibernate.connection.provider_class "> org.hibernate.connection.C3P0ConnectionProvider </property>
<property   name= "hibernate.c3p0.max_size "> 20 </property>
<property   name= "hibernate.c3p0.min_size "> 5 </property>
<property   name= "hibernate.c3p0.timeout "> 120 </property>
<property   name= "hibernate.c3p0.max_statements "> 100 </property>
<property   name= "hibernate.c3p0.idle_test_period "> 120 </property>
<property   name= "hibernate.c3p0.acquire_increment "> 2 </property>

<property   name= "dialect "> org.hibernate.dialect.SQLServerDialect </property>
<property   name= "show_sql "> true </property>



<mapping   resource= "ExLogin.hbm.xml "   />
</session-factory>
</hibernate-configuration>

但在运行的是报出
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.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:88)
at   org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1162)
at   org.hibernate.loader.Loader.doQuery(Loader.java:390)
at   org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at   org.hibernate.loader.Loader.doList(Loader.java:1593)
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