Re: Combining two methods into one
- From: efriedNoSpam@xxxxxxxxx (EricF)
- Date: Tue, 09 Oct 2007 03:27:20 GMT
In article <1191879284.502523.61430@xxxxxxxxxxxxxxxxxxxxxxxxxxx>, mark.donaghue@xxxxxxxxx wrote:
On Oct 8, 11:39 am, "Matt Humphrey" <ma...@xxxxxxxxxxxxxx> wrote:Maybe that doesn't fit his homework assignment?
<franca...@xxxxxxxxx> wrote in message<franca...@xxxxxxxxx> wrote in message
news:1191850898.200358.174320@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| On Oct 8, 9:18 am, "Matt Humphrey" <ma...@xxxxxxxxxxxxxx> wrote:| >
| >
| >news:1191814290.364893.103730@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| > |I have a 2 methods working in my class file that I am trying to
| > | convert into 1 method:
| > |
| >
| > <snip code>
| >
| > Your combined insert will definately fail because the table has only 2
| > fields but you are attempting to assign 4 fields. Fields 3 and 4 don't
| > exist. You original code shows that the insertion should create 2
rows--two
| > distinct insertions. You will have to duplicate the executeUpdate()
portion
| > to achieve that. Something like:
| >
| > prep.connection.preparestatement("insert into person (city, state)
values
| > (?,?)");
| > prep.setString(1,mybean.getCity());
| > prep.setString(2,mybean.getState());
| > prep.executeUpdate();
| >
| > prep.setString(1,mybean.getMainCity());
| > prep.setString(2,mybean.getMainState());
| > prep.executeUpdate();
| >
| > I'm just copying your words--I have no idea what your "prep" object is
or
| > how it works.
| >
| > Matt Humphreyhttp://www.iviz.com/
|
| Thanks,
|
| How would I call the method where the method would know what to
| execute? Would I just call it like this?
| inserterCombined(mybean);
I would think so, although doing so assumes that the bean is fully defined
for City/State, MainCity/MainState.
How about a method like this:
public int inserterOne(String city, String State)
Call it the first time for city/state, the second time with mainCity/
mainState.
.
- References:
- Combining two methods into one
- From: francan00
- Re: Combining two methods into one
- From: Matt Humphrey
- Re: Combining two methods into one
- From: francan00
- Re: Combining two methods into one
- From: Matt Humphrey
- Re: Combining two methods into one
- From: mark . donaghue
- Combining two methods into one
- Prev by Date: Re: How to download metafiles using a signed applet
- Next by Date: Re: notifying particular thread to wake up.
- Previous by thread: Re: Combining two methods into one
- Next by thread: Java API for communicating with USB GPS Device
- Index(es):
Relevant Pages
|