关于Hibernate连接数据库问题
我在配置连接池时出错了,请大家给点办法:
hibernate.cfg.xml
<property name= "connection.username "> hbdzjgxt </property>
<property name= "connection.url ">
jdbc:sybase:Tds:10.10.10.4:5000/hbdzjgxt </property>
<property name= "dialect "> org.hibernate.dialect.SybaseDialect </property>
<property name= "connection.password "> hbdzjgxt </property>
<property name= "connection.driver_class ">
com.sybase.jdbc3.jdbc.SybDriver </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>
<mapping resource= "userinfo.hbm.xml " />
Dao调用:
SessionFactory sessionFactory =
new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
tx = session.beginTransaction();
Query q = session.createQuery(HQL);
list = q.list();
tx.commit();
总抱错:
org.hibernate.exception.GenericJDBCException: Cannot open connection
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
org.hibernate.exception.
JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
com.dzjg.logon.LogonAction.execute(LogonAction.java:36)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
我已经把c3p0包 加到path中了
------解决方案--------------------使用dbcp试试看!
------解决方案--------------------反正是联接出错!你写个直连的或者jdbc的看看不行么?不太懂!
------解决方案-------------------