The strange thing is when I first vist the web page, it works. But when I refresh the page, it throwed the exception below
ps:I use eclipse with myeclipse plugin.
Hibernate version:3
the exception:
[code]java.lang.RuntimeException: org.hibernate.HibernateException: Not able to obtain connection
com.cqgdcc.hibernate.CustomerService.getCustomersList(CustomerService.java:86)
org.apache.jsp.display_jsp._jspService(display_jsp.java:98)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)[code]
My code:
[code]public List getCustomersList(){
Session session = null;
try{
session = HibernateSessionFactory.currentSession();
Query query = session.createQuery(
"select Customers from com.cqgdcc.hibernate.Customers Customers");
return query.list();
}catch(HibernateException he){
System.err.println("Hibernate Excepton "+ he.getMessage());
throw new RuntimeException(he);
}finally{[/code]
Name and version of the database i am using:oracle 9i
|