--- Mike Zatko <[EMAIL PROTECTED]> wrote:
> Thanks! It's all so clear now! Also, I was making a fatal assumption 
> when I was trying to do this before that maybe should be noted. Usually,
> 
> from what I've seen if you have a column name in a database called 
> LAST_NAME when you make a java bean you'd map it to lastName without an 
> underscore and I guess I was inferring that dbutils would do this also. 
> Maybe that would be a nice option to put into the classes at some point.
> 

Trying to accomodate everyone's db column naming conventions is futile. 
There are now two methods of mapping column names to bean property names:
1.  Use an SQL "AS" to change the column names to match properties.
2.  Implement the ColumnProcessor interface's mapColumnsToProperties
method.  This requires a nightly build because it was added after 1.0.

> Anyway, thanks alot. I'll investigate how to contribute to an apache 
> project and maybe write up a better example page if I can.

I added some more examples this weekend; further additions are welcome
:-).

David

> 
> Thanks
> 
> 
> Tatu Vanhanen wrote:
> 
> >I must confess that I have not used DBUtils and am not a pro in DBCP
> but
> >anyway here comes what I found.
> >
> >  
> >
> >>lled printDriverStats() and shutdownDriver(). The former uses what
> >>appears to be a protected method called getConnectionPool(String) in
> the
> >>Class PoolingDriver.
> >>    
> >>
> >
> >There appears to be a method getPool(String), although that is
> deprecated.
> >The javadoc says that it is to be replaced with the protected
> >getConnectionPool(String), but for now the getPool is the one to use.
> >
> >  
> >
> >>The latter has a similar problem with the PoolingDriver Class except
> >>instead of being protected, eclipse tells me its undefined. The method
> >>is closePool(String).
> >>    
> >>
> >
> >Did not find a closePool(String) in PoolingDriver, but you can probably
> call
> >ObjectPool.close() to close the pool. The ObjectPool is returned from
> >getPool(String).
> >
> >  
> >
> >>I gather the QueryRunner is designed to execute an sql query and give
> >>you an object you define instead of a ResultSet. The example nor the
> >>apis really tell you what the ResultSetHandler is doing. And what kind
> >>of bean are you supposed to setup? I mean, if you do a SELECT * on
> some
> >>table you can get alot of rows back, but with the QueryRunner you only
> >>get a single object back. And I'm guessing you define that object
> >>yourself. But, is that bean supposed to represent a row of the table
> >>returned from your query? If it is, how do you access all of the rows.
> >>    
> >>
> >
> >The Object returned depends of what kind of ResultSetHandler you pass
> to the
> >query method. You can of course make your own handler (like you did),
> but
> >there are also ready-made ones available. Look at the javadocs of
> >BeanHandler, ListHandler, etc. For eaxmple, if you know that your query
> >contains only one row, you can pass a BeanHandler (the default works,
> don't
> >have to implement it!) configured with the expected bean class like
> >OrderBean order = (OrderBean) runner.query(conn, "SELECT ORDER_ID,
> TOTAL_AMT
> >FROM ORDERS", new BeanHandler(OrderBean.class));
> >
> >and voil�, you get an OrderBean back.
> >
> >If you want a list of OrderBean:s, use a BeanListHandler:
> >List orders = (List) runner.query(conn, "SELECT ORDER_ID, TOTAL_AMT
> FROM
> >ORDERS", new BeanListHandler(OrderBean.class));
> >
> >Now every item in the list is an OrderBean.
> >
> >No magic here; only great stuff that great folks have done for everyone
> to
> >use =)
> >
> >- Tatu V.
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >  
> >
> 
> 


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to