commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: [DBUtils] Introduction and some thoughts
Date Fri, 15 Nov 2002 12:50:14 GMT
From: "Mike Bryant" <mike@mikebryant.com>
> Hello all,
>
> My name is Mike Bryant.  I just wanted to send an email to introduce
> myself and say that I am excited about the DBUtils package.  I've spent a
> good bit of time at my current job writing database utility code, a
> package like this could have really saved some time.
>
> The code so far looks great I think.  I am especially impressed with the
> EnhancedResultSet class and the DbUtils.resultSetToArray method.
>
> Some thoughts I have on this package:
> - Data class (ColumnData) to hold a DB field's data.  This might contain
> data like column index, data type, column name, value.

In the commons-sql project I used a DynaBean to hold a row of data from a
database.  See the bottom of this page for it in action..

http://jakarta.apache.org/commons/sandbox/sql/

A DynaBean has a DynaClass and a DynaProperty for the metadata. So I just
implemented an SqlDynaBean, SqlDynaClass and SqlDynaProperty so that the
additional database-specific metadata can be captured (SQL types, primary
keys, indices, auto-increment, nullable, foreign keys etc).

http://jakarta.apache.org/commons/sandbox/sql/apidocs/org/apache/commons/sql
/dynabean/package-summary.html

e.g. an SqlDyanBean has a collection of SqlDynaProperty objects each of
which refers to a Column definition...

http://jakarta.apache.org/commons/sandbox/sql/apidocs/org/apache/commons/sql
/model/Column.html


would that do for now?


> - Method (similar to DbUtils.resultSetToArray method) that would build a
> List (or maybe Map) of ColumnData objects.  This might be useful if users
> need more information than the resultSetToArray method provides.

Already the beanutils project has a way of turning a ResultSet into an
Iterator over DynaBeans which is quite useful.


> - Method to take a SQL stmt as a param, execute it, build a List of
> ColumnData objects (or a List of Strings), representing a vertical list of
> column data.  An example of this would be to use a stmt like 'select
> user_name from users' to get a List of all users.

FWIW the DynaSql class provides a way to preform queries and get the results
back as an iterator over DyanBeans as well as to perform inserts and updates
via DynaBeans.

http://jakarta.apache.org/commons/sandbox/sql/apidocs/org/apache/commons/sql
/dynabean/DynaSql.html


James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message