[
https://issues.apache.org/jira/browse/DBUTILS-38?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dennis Lundberg updated DBUTILS-38:
-----------------------------------
Description:
Hello,
I came across DBUtils:
http://jakarta.apache.org/commons/dbutils/examples.html
and I found your contact email:
http://jakarta.apache.org/commons/dbutils/team-list.html
In this example page, you show how to query a db, and get a bean object:
{code}
QueryRunner run = new QueryRunner(dataSource);
ResultSetHandler h = new BeanHandler(Person.class);
Person p = (Person) run.query("SELECT * FROM Person WHERE name=?", "John Doe",
h);
{code}
It would be great to show also that it can handle list of objects:
{code}
QueryRunner run = new QueryRunner(dataSource);
ResultSetHandler h = new BeanHandler(Person.class);
List list = (List) run.query("SELECT * FROM Person WHERE name=?", "John Doe",
h);
while (Person p : list)
System.out.println(p);
{code}
or something like this.
More importantly, it is not obvious how to execute an update query, using a
bean object.
I did not find it in the documentation.
Would it be something like this?
{code}
QueryRunner run = new QueryRunner(dataSource);
ResultSetHandler h = new BeanHandler(Person.class);
Person p = (Person) run.query("SELECT * FROM Person WHERE name=?", "John Doe",
h);
p.setName("new name");
run.update("UPDATE Person WHERE name = "John Doe", p);
{code}
Could you please add the correct example in your example documentation webpage?
Regards,
DAvid Portabella
was:
Hello,
I came across DBUtils:
http://jakarta.apache.org/commons/dbutils/examples.html
and I found your contact email:
http://jakarta.apache.org/commons/dbutils/team-list.html
In this example page, you show how to query a db, and get a bean object:
QueryRunner run = new QueryRunner(dataSource);
ResultSetHandler h = new BeanHandler(Person.class);
Person p = (Person) run.query("SELECT * FROM Person WHERE name=?", "John Doe",
h);
It would be great to show also that it can handle list of objects:
QueryRunner run = new QueryRunner(dataSource);
ResultSetHandler h = new BeanHandler(Person.class);
List list = (List) run.query("SELECT * FROM Person WHERE name=?", "John Doe",
h);
while (Person p : list)
System.out.println(p);
or something like this.
More importantly, it is not obvious how to execute an update query, using a
bean object.
I did not find it in the documentation.
Would it be something like this?
QueryRunner run = new QueryRunner(dataSource);
ResultSetHandler h = new BeanHandler(Person.class);
Person p = (Person) run.query("SELECT * FROM Person WHERE name=?", "John Doe",
h);
p.setName("new name");
run.update("UPDATE Person WHERE name = "John Doe", p);
Could you please add the correct example in your example documentation webpage?
Regards,
DAvid Portabella
> example documentation page, update query
> ----------------------------------------
>
> Key: DBUTILS-38
> URL: https://issues.apache.org/jira/browse/DBUTILS-38
> Project: Commons DbUtils
> Issue Type: Improvement
> Reporter: David Portabella
> Priority: Minor
>
> Hello,
> I came across DBUtils:
> http://jakarta.apache.org/commons/dbutils/examples.html
> and I found your contact email:
> http://jakarta.apache.org/commons/dbutils/team-list.html
> In this example page, you show how to query a db, and get a bean object:
> {code}
> QueryRunner run = new QueryRunner(dataSource);
> ResultSetHandler h = new BeanHandler(Person.class);
> Person p = (Person) run.query("SELECT * FROM Person WHERE name=?", "John
> Doe", h);
> {code}
> It would be great to show also that it can handle list of objects:
> {code}
> QueryRunner run = new QueryRunner(dataSource);
> ResultSetHandler h = new BeanHandler(Person.class);
> List list = (List) run.query("SELECT * FROM Person WHERE name=?", "John Doe",
> h);
> while (Person p : list)
> System.out.println(p);
> {code}
> or something like this.
> More importantly, it is not obvious how to execute an update query, using a
> bean object.
> I did not find it in the documentation.
> Would it be something like this?
> {code}
> QueryRunner run = new QueryRunner(dataSource);
> ResultSetHandler h = new BeanHandler(Person.class);
> Person p = (Person) run.query("SELECT * FROM Person WHERE name=?", "John
> Doe", h);
> p.setName("new name");
> run.update("UPDATE Person WHERE name = "John Doe", p);
> {code}
> Could you please add the correct example in your example documentation
> webpage?
> Regards,
> DAvid Portabella
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.