You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Stefan Edlich <ed...@gmx.net> on 2004/03/18 22:50:16 UTC
[DbUtils] 2 Questions
Dear DbUtils Crew or Users,
I have 2 perhaps simple questions:
1. I have slight problems running the DbUtil Tools from the first website
example.
No problem occurs when using the BeanHandler as a Result Set Handler
to get just one bean back. This is well done.
But the example on the website should return an object array but it crashes.
The result set looks fine but the new ResultSetHandler calls rs.getObject(i
+ 1);
which causes the following exception:
java.sql.SQLException: No data is available Query: SELECT * FROM Person
WHERE age=37 Parameters: [
at org.apache.commons.dbutils.QueryRunner.rethrow(QueryRunner.java:330)
at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:213)
at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:236)
at de.commonsbuch.dbutils.Read2BeanArray.main(Read2BeanArray.java:44)
I am running hsqldb1.7.1 but the error might be thrown by
java.sql.ResultSet.getObject
Any idea what's could be wrong?
2. If you like to query for an Integer and you are using replacement
parameters with this
query method:
query(java.sql.Connection conn, java.lang.String sql, java.lang.Object
param, ResultSetHandler rsh)
Execute an SQL SELECT query with a single replacement parameter.
How do you enter an Integer to search for? (new Integer(37)) won't work.
Thanks in advance
Stefan E
--
<mailto: stefan@edlich.de>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [DbUtils] 2 Questions
Posted by David Graham <gr...@yahoo.com>.
1. Please send the code that calls QueryRunner including any custom
ResultSetHandler implementation you're using.
2. Passing an Integer object is only required to work if the column is
defined as an INTEGER. Refer to appendix B in the 3.0 JDBC spec for type
mapping info. As a last resort, you could override
QueryRunner.fillStatement() to work around any bugs in your driver.
David
--- Stefan Edlich <ed...@gmx.net> wrote:
> Dear DbUtils Crew or Users,
>
> I have 2 perhaps simple questions:
>
> 1. I have slight problems running the DbUtil Tools from the first
> website
> example.
> No problem occurs when using the BeanHandler as a Result Set Handler
> to get just one bean back. This is well done.
>
> But the example on the website should return an object array but it
> crashes.
> The result set looks fine but the new ResultSetHandler calls
> rs.getObject(i
> + 1);
> which causes the following exception:
> java.sql.SQLException: No data is available Query: SELECT * FROM Person
> WHERE age=37 Parameters: [
> at org.apache.commons.dbutils.QueryRunner.rethrow(QueryRunner.java:330)
> at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:213)
> at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:236)
> at de.commonsbuch.dbutils.Read2BeanArray.main(Read2BeanArray.java:44)
> I am running hsqldb1.7.1 but the error might be thrown by
> java.sql.ResultSet.getObject
> Any idea what's could be wrong?
>
> 2. If you like to query for an Integer and you are using replacement
> parameters with this
> query method:
> query(java.sql.Connection conn, java.lang.String sql, java.lang.Object
> param, ResultSetHandler rsh)
> Execute an SQL SELECT query with a single replacement
> parameter.
>
> How do you enter an Integer to search for? (new Integer(37)) won't work.
>
> Thanks in advance
> Stefan E
>
> --
> <mailto: stefan@edlich.de>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org