Re: Combining two methods into one



In article <1191879284.502523.61430@xxxxxxxxxxxxxxxxxxxxxxxxxxx>, mark.donaghue@xxxxxxxxx wrote:
On Oct 8, 11:39 am, "Matt Humphrey" <ma...@xxxxxxxxxxxxxx> wrote:
<franca...@xxxxxxxxx> wrote in message

news:1191850898.200358.174320@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| On Oct 8, 9:18 am, "Matt Humphrey" <ma...@xxxxxxxxxxxxxx> wrote:| >
<franca...@xxxxxxxxx> wrote in message

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


Maybe that doesn't fit his homework assignment?
.



Relevant Pages

  • Re: Combining two methods into one
    ... You will have to duplicate the executeUpdate() ... Call it the first time for city/state, ...
    (comp.lang.java.programmer)
  • Re: output to STDOUT to a file
    ... >> inside the perl script. ... > in-place file editing. ... [snip code that reads from backup and saves to original] ... I loved the module so much after using it for the first time that I ...
    (comp.lang.perl.misc)
  • Re: Combining two methods into one
    ... |> Your combined insert will definately fail because the table has only 2 ... |> distinct insertions. ... You will have to duplicate the executeUpdate() ...
    (comp.lang.java.programmer)
  • Re: Combining two methods into one
    ... |I have a 2 methods working in my class file that I am trying to ... distinct insertions. ... You will have to duplicate the executeUpdate() portion ...
    (comp.lang.java.programmer)
  • Re: DirectShow heap memory leak
    ... I still lose over 1 Mb of heap space every time I run the ... >run, even the first time. ... It looks like you are releasing the references properly, ...
    (microsoft.public.windowsce.embedded.vc)