Hibernate version: 3.0
Mapping documents:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- datasource connection properties -->
<property name="connection.datasource">java:comp/env/jdbc/Book</property>
<property name="hibernate.connection.username">hibernate</property>
<property name="hibernate.connection.password">hibernate</property>
<!-- dialect for MySQL -->
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.connection.provider_class">
org.hibernate.connection.DatasourceConnectionProvider
</property>
<property name="hibernate.jdbc.fetch_size">50</property>
<property name="hibernate.jdbc.batch_size">25</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>
<property name="jta.UserTransaction">
java:comp/UserTransaction
</property>
<mapping resource="TauthBook.hbm.xml" />
<mapping resource="Tauthor.hbm.xml" />
<mapping resource="Tbook.hbm.xml"></mapping>
</session-factory>
</hibernate-configuration>
Code between sessionFactory.openSession() and session.close():
public class TestServlet extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse resp) throws IOException{
PrintWriter out = resp.getWriter();
Configuration config = new Configuration().configure();
SessionFactory sessionFactory = config.buildSessionFactory();
Session session = sessionFactory.openSession();
String hql = " from Tbook";
Query query = session.createQuery(hql);
Iterator iter = query.iterate();
Tbook info = null;
while (iter.hasNext()){
info = (Tbook)iter.next();
}
}
}
Full stack trace of any exception that occurs:
java.lang.UnsupportedOperationException
org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:116)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:554)
org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:57)
org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:416)
org.hibernate.jdbc.JDBCContext.connect(JDBCContext.java:145)
org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:91)
org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:86)
org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1098)
org.hibernate.loader.hql.QueryLoader.iterate(QueryLoader.java:415)
org.hibernate.hql.ast.QueryTranslatorImpl.iterate(QueryTranslatorImpl.java:281)
org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:876)
org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:41)
cn.edu.shu.test.TestServlet.doGet(TestServlet.java:48)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Name and version of the database you are using:
mysql
the error occure when i invoke the iterator() of query,how can i do with the error?
|