Closing a result set you left open!, MySQL
marcusdidiusfalco Sep 28, 2007 9:04 AMHi, I am just beginning to experiment with JPA.
I have jboss-4.2.1.GA and MySQL 5.0.45 community installed and I am using mysql-connector-java-5.0.6 as JDBC driver.
With
@Stateless
public class TestBean implements TestRemote {
 @PersistenceContext(unitName="ejbbuch")
 EntityManager entityManager;
 @TransactionAttribute(TransactionAttributeType.REQUIRED)
 public Product addProduct(Product product) {
 entityManager.persist(product);
 return product;
 }
 .....
---------------------------------------------------------------------------------
@Entity
public class Product implements Serializable {
 @Id
 @GeneratedValue(strategy=GenerationType.IDENTITY)
 private long id;
 ........
-------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<persistence>
 <persistence-unit name="ejbbuch">
 <jta-data-source>java:/MySqlDS</jta-data-source>
 </persistence-unit>
</persistence>
---------------------------------------------------------------------------------
<datasources>
 <local-tx-datasource>
 <jndi-name>MySqlDS</jndi-name>
 <connection-url>jdbc:mysql://localhost:3306/jbossdb</connection-url>
 <driver-class>com.mysql.jdbc.Driver</driver-class>
 <user-name>root</user-name>
 <password>ritak1</password>
 <min-pool-size>6</min-pool-size>
 <max-pool-size>20</max-pool-size>
 <blocking-timeout-millis>5000</blocking-timeout-millis>
 <idle-timeout-minutes>0</idle-timeout-minutes>
 <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
 <!-- should only be used on drivers after 3.22.1 with "ping" support
 -->
 <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
 <new-connection-sql>SELECT count(*) FROM product</new-connection-sql>
 <check-valid-connection-sql>SELECT count(*) FROM product</check-valid-connection-sql>
 <share-prepared-statements>true</share-prepared-statements>
 <prepared-statement-cache-size>10</prepared-statement-cache-size>
 <track-statements>true</track-statements>
 <metadata>
 <type-mapping>mySQL</type-mapping>
 </metadata>
 </local-tx-datasource>
</datasources>
I get the following exceptions in the log file:
2007-09-28 13:41:04,265 WARN [org.jboss.resource.adapter.jdbc.WrappedConnection] Closing a result set you left open! Please close it yourself. java.lang.Throwable: STACKTRACE at org.jboss.resource.adapter.jdbc.WrappedStatement.registerResultSet(WrappedStatement.java:617) at org.jboss.resource.adapter.jdbc.WrappedStatement.getGeneratedKeys(WrappedStatement.java:533) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
When I switch back to the DefaultDS (HSQL) this disappears.
Otherwise the code works as expected with the MySQL database. But of course in a production environment you would not want to force JBoss to handle unclosed statements or resultsets.
Is this some problem with the JDBC driver or do I have some bug in my code?
Thanks,
Hans
 
    