commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charl Gerber <charlger...@yahoo.com>
Subject Re: DBUtils BeanListHandler
Date Mon, 11 Dec 2006 09:55:24 GMT
Yeah, thanks ... 10 minutes after I sent the mail, I thought about just that and will try it.
I'm pretty sure it will work.



----- Original Message ----
From: Tahir Akhtar <tahir@spectrum-tech.com>
To: Jakarta Commons Users List <commons-user@jakarta.apache.org>
Sent: Monday, 11 December, 2006 10:48:22 AM
Subject: RE: DBUtils BeanListHandler

I would say you need to implement a no-args constructor and expose the bean
attributes as JavaBean getter/setter. Just a guess :)

-----Original Message-----
From: Charl Gerber [mailto:charlgerber@yahoo.com] 
Sent: Monday, December 11, 2006 2:24 PM
To: commons-user@jakarta.apache.org
Subject: DBUtils BeanListHandler

Hi,

Is there any special conditions your Bean has to comply to when using the
default BeanListHandler? I have a class:

public class KeyValuePair
{

    private String _key;
    private String _value;

    public KeyValuePair(String key, String value)
    {
        _key   = key;
        _value = value;
    }


etc, with all the proper getters & setters. I then create this DBUtil code:

List results = (List)runner.query("SELECT someField as key,anotherField as
value FROM myTable", new BeanListHandler(KeyValuePair.class));

(Simplified SQL)

It just gives me this exception with no further explanation:

java.sql.SQLException: Cannot create com.caes.sonora.util.KeyValuePair:
com.caes.sonora.util.KeyValuePair Query: SELECT SONORAFIELDS.FIELDNAME as
key,SONORAFIELDS.DEFAULTNAME as value FROM SONORAFIELDS,SONORACOLUMNS WHERE
SONORACOLUMNS.TABLEID=? AND SONORAFIELDS.ENUMERATION=1 AND
SONORAFIELDS.FIELDNAME=SONORACOLUMNS.FIELDNAME ORDER BY DEFAULTNAME ASC
Parameters: [81]
    at org.apache.commons.dbutils.QueryRunner.rethrow(QueryRunner.java:359)
    at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:240)
    at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:309)
    at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:285)
    at
com.caes.struts.action.routing.CreateChoiceInitAction.getEnumerationFields(U
nknown Source)
    at
com.caes.struts.action.routing.CreateChoiceInitAction.getFields(Unknown
Source)
    at com.caes.struts.action.routing.CreateValueInitAction.execute(Unknown
Source)
    at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces
sor.java:419)
    at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
    at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServle
tInstance.java:110)
    at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecy
cleServlet.java:174)
    at
com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServ
let.java:313)
    at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecyc
leServlet.java:116)
    at
com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java
:283)
    at
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidSer
vletReferenceState.java:42)
    at
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletIns
tanceReference.java:40)
    at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(
WebAppRequestDispatcher.java:1018)
    at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppReques
tDispatcher.java:529)
    at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequest
Dispatcher.java:208)
    at
com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:134)
    at
com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker
.java:321)
    at
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(C
achedInvocation.java:71)
    at
com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletReq
uestProcessor.java:246)
    at
com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListene
r.java:334)
    at
com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.jav
a:56)
    at
com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:652)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:458)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:936)


My guess is my class has to implement a contructor that takes the ResultSet
or something like that?

Thanks!

Charl




Send instant messages to your online friends http://uk.messenger.yahoo.com 

---------------------------------------------------------------------
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





Send instant messages to your online friends http://uk.messenger.yahoo.com 

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


Mime
View raw message