You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mike Zatko <za...@comcast.net> on 2004/02/07 01:12:20 UTC

[DBUTILS] How to handle and int

Hello,
    This should be a very simple question. I am pulling in a table in a 
query that contains a bunch of Strings and an Integer. It works fine 
except its not getting the values for the ints. How do I map the 
database integer column to my bean? I've tried using int, Integer, and 
String, but none work.


public class MerchantBean {
   
    private String partNumber;
    private String description;
    private String name;
    private String thumbnail;
    private String picture;
    private String identifier;
    private int groupId;

...
}



Heres the snippet of code, nothing spectacular:

        runner = new QueryRunner();
        handler =
            new BeanListHandler(MerchantBean.class);
        List merchantRecords =
            (List)runner.query(conn, 
configuration.getMerchantFileQuery(), handler);


Everything works fine except I get 0's for my groupId field. Any ideas?
Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [DBUTILS] How to handle and int

Posted by Mike Zatko <za...@comcast.net>.
Oops, Here is the SQL i'm executing:

SELECT e.mfpartnumber as PARTNUMBER, desc.longdescription as 
DESCRIPTION, desc.name as NAME, desc.thumbnail as THUMBNAIL, 
g.identifier as IDENTIFIER, g.catgroup_id as GROUPID
        FROM DB2USR.catentry e, DB2USR.catgroup g, DB2USR.catentdesc 
desc, DB2USR.catgpenrel rel
        WHERE e.catentry_id = desc.catentry_id
        AND e.member_id=g.member_id
        AND rel.catentry_id = e.catentry_id
        AND rel.catgroup_id = g.catgroup_id
        AND rel.sequence = 1
        ORDER BY PARTNUMBER


Mike Zatko wrote:

> Hello,
>    This should be a very simple question. I am pulling in a table in a 
> query that contains a bunch of Strings and an Integer. It works fine 
> except its not getting the values for the ints. How do I map the 
> database integer column to my bean? I've tried using int, Integer, and 
> String, but none work.
>
>
> public class MerchantBean {
>      private String partNumber;
>    private String description;
>    private String name;
>    private String thumbnail;
>    private String picture;
>    private String identifier;
>    private int groupId;
>
> ...
> }
>
>
>
> Heres the snippet of code, nothing spectacular:
>
>        runner = new QueryRunner();
>        handler =
>            new BeanListHandler(MerchantBean.class);
>        List merchantRecords =
>            (List)runner.query(conn, 
> configuration.getMerchantFileQuery(), handler);
>
>
> Everything works fine except I get 0's for my groupId field. Any ideas?
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [DBUTILS] How to handle and int

Posted by David Graham <gr...@yahoo.com>.
http://jakarta.apache.org/commons/dbutils/apidocs/org/apache/commons/dbutils/BasicRowProcessor.html

Notice that there is a constructor that accepts a ColumnProcessor.  All
you need to do is this:

new BasicRowProcessor(new BasicColumnProcessor());

David

--- Mike Zatko <za...@comcast.net> wrote:
> I've downloaded the latest build, but I am unsure as to where the 
> BasicColumnProcessor class fits in. The mapColumnsToProperties method 
> requires ResultSetMetaData which is hidden inside the BeanListHandler in
> 
> my own code. Does this mean I'd have to write my own Handler? Are there 
> any examples on this anywhere?
> 
> Thanks
> 
> 
> David Graham wrote:
> 
> >Grab a nightly build and use the BasicColumnProcessor class.  This is
> such
> >a common problem that we should probably release 1.1 soon.
> >
> >David
> >
> >--- Mike Zatko <za...@comcast.net> wrote:
> >  
> >
> >>Hello,
> >>    This should be a very simple question. I am pulling in a table in
> a 
> >>query that contains a bunch of Strings and an Integer. It works fine 
> >>except its not getting the values for the ints. How do I map the 
> >>database integer column to my bean? I've tried using int, Integer, and
> 
> >>String, but none work.
> >>
> >>
> >>public class MerchantBean {
> >>   
> >>    private String partNumber;
> >>    private String description;
> >>    private String name;
> >>    private String thumbnail;
> >>    private String picture;
> >>    private String identifier;
> >>    private int groupId;
> >>
> >>...
> >>}
> >>
> >>
> >>
> >>Heres the snippet of code, nothing spectacular:
> >>
> >>        runner = new QueryRunner();
> >>        handler =
> >>            new BeanListHandler(MerchantBean.class);
> >>        List merchantRecords =
> >>            (List)runner.query(conn, 
> >>configuration.getMerchantFileQuery(), handler);
> >>
> >>
> >>Everything works fine except I get 0's for my groupId field. Any
> ideas?
> >>Thanks.
> >>
> >>---------------------------------------------------------------------
> >>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! Finance: Get your refund fast by filing online.
> >http://taxes.yahoo.com/filing.html
> >
> >---------------------------------------------------------------------
> >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! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [DBUTILS] How to handle and int

Posted by Mike Zatko <za...@comcast.net>.
I've downloaded the latest build, but I am unsure as to where the 
BasicColumnProcessor class fits in. The mapColumnsToProperties method 
requires ResultSetMetaData which is hidden inside the BeanListHandler in 
my own code. Does this mean I'd have to write my own Handler? Are there 
any examples on this anywhere?

Thanks


David Graham wrote:

>Grab a nightly build and use the BasicColumnProcessor class.  This is such
>a common problem that we should probably release 1.1 soon.
>
>David
>
>--- Mike Zatko <za...@comcast.net> wrote:
>  
>
>>Hello,
>>    This should be a very simple question. I am pulling in a table in a 
>>query that contains a bunch of Strings and an Integer. It works fine 
>>except its not getting the values for the ints. How do I map the 
>>database integer column to my bean? I've tried using int, Integer, and 
>>String, but none work.
>>
>>
>>public class MerchantBean {
>>   
>>    private String partNumber;
>>    private String description;
>>    private String name;
>>    private String thumbnail;
>>    private String picture;
>>    private String identifier;
>>    private int groupId;
>>
>>...
>>}
>>
>>
>>
>>Heres the snippet of code, nothing spectacular:
>>
>>        runner = new QueryRunner();
>>        handler =
>>            new BeanListHandler(MerchantBean.class);
>>        List merchantRecords =
>>            (List)runner.query(conn, 
>>configuration.getMerchantFileQuery(), handler);
>>
>>
>>Everything works fine except I get 0's for my groupId field. Any ideas?
>>Thanks.
>>
>>---------------------------------------------------------------------
>>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! Finance: Get your refund fast by filing online.
>http://taxes.yahoo.com/filing.html
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>  
>


Re: [DBUTILS] How to handle and int

Posted by David Graham <gr...@yahoo.com>.
Grab a nightly build and use the BasicColumnProcessor class.  This is such
a common problem that we should probably release 1.1 soon.

David

--- Mike Zatko <za...@comcast.net> wrote:
> Hello,
>     This should be a very simple question. I am pulling in a table in a 
> query that contains a bunch of Strings and an Integer. It works fine 
> except its not getting the values for the ints. How do I map the 
> database integer column to my bean? I've tried using int, Integer, and 
> String, but none work.
> 
> 
> public class MerchantBean {
>    
>     private String partNumber;
>     private String description;
>     private String name;
>     private String thumbnail;
>     private String picture;
>     private String identifier;
>     private int groupId;
> 
> ...
> }
> 
> 
> 
> Heres the snippet of code, nothing spectacular:
> 
>         runner = new QueryRunner();
>         handler =
>             new BeanListHandler(MerchantBean.class);
>         List merchantRecords =
>             (List)runner.query(conn, 
> configuration.getMerchantFileQuery(), handler);
> 
> 
> Everything works fine except I get 0's for my groupId field. Any ideas?
> Thanks.
> 
> ---------------------------------------------------------------------
> 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! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org