10 messages in com.mysql.lists.javaRe: Problem with com.mysql.jdbc.Resul...| From | Sent On | Attachments |
|---|---|---|
| Marco Tedone | 05 Aug 2003 00:37 | |
| Mark Matthews | 05 Aug 2003 06:05 | |
| Trever M. Shick | 05 Aug 2003 06:29 | |
| Mark Matthews | 05 Aug 2003 07:15 | |
| Marco Tedone | 05 Aug 2003 07:35 | |
| Trever M. Shick | 05 Aug 2003 08:08 | |
| Marco Tedone | 05 Aug 2003 08:15 | |
| Mark Matthews | 05 Aug 2003 08:26 | |
| LAFO...@lyon-partdieu.sema.slb.com) | 05 Aug 2003 08:27 | |
| Steve Forsyth | 05 Aug 2003 11:23 |
| Subject: | Re: Problem with com.mysql.jdbc.ResultSet not serializable![]() |
|---|---|
| From: | Mark Matthews (ma...@mysql.com) |
| Date: | 08/05/2003 06:05:39 AM |
| List: | com.mysql.lists.java |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Marco Tedone wrote:
Hi, our application needs a ResultSet obtained after a query. The client is a web application (running on Tomcat), while the database is queried through a session bean running in Jboss. At the beginning the type returned by the interface method was ResultSet, but then we obtained the following exception:
Exception while executing the query: java.io.NotSerializableException: com.mysql.jdbc.ResultSet
So we tried to defined the return type as Object (which is serializable) but the result is the same. I tried also to put the ResultSet in a List obtaining the same result.
Here follows part of the code (warning, it contains some encapsulated methods) to create the ResultSet:
try { ps = connect().prepareStatement(queryString); if (ps != null) { dbData = ps.executeQuery(); }
The dbData variable, when the query is executed contains the following, retrieved by Jboss console:
com.mysql.jdbc.ResultSet
The question is: how could I pass a ResultSet from Jboss to my client (please note that the record format is unknow at compile time, as the query is built dynamically)?
Thanks for any help,
Marco
ResultSets in JDBC are _not_ serializable, usually because they have to maintain a reference to the Connection to the database, which is not serializable. That is why there is the 'data transfer object' pattern. Your session bean shouldn't be passing back result sets, it should be passing back instances of business objects that have been created using data from the database. See any of the decent EJB books from O'Reiley or Wiley to see how it's done in detail.
-Mark
- -- Mr. Mark Matthews MySQL AB, Software Development Manager, J2EE and Windows Platforms Office: +1 708 557 2388 www.mysql.com
Are you MySQL Certified? http://www.mysql.com/certification/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQE/L6u4tvXNTca6JD8RAgVhAKC3KuvCBQMefgyiba7nbPFifcCY+QCgnYqi +oE+civX681YacGu/K+D2Qk= =nR0f -----END PGP SIGNATURE-----




