File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple preparedStatements 1 Connection

 
rastas biggs
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not to sure if I'm doing this correctly, well as a matter of fact I'd say I'm not as the Update although not returning an error is not updating the second statement ps2.

The ps statement executes OK its the second one that won't execute.

What I'm doing is pulling data writing to a file to ftp across the ether, then I'm storing the PK in a vector in the query loop.

Then I get the values from the vector to use as the argument in this case mobile_phone_number in ststement 2 ps2.

I don't think the batch is executing can some one give me a hand with this.


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33713
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rastas,
Where are you closing the resultsets? It is good practice to do this near where you close the prepared statement.

Also, not that the executeBatch returns an array of integers. So on failure, these integers can be zero rather than throw an exception.
 
rastas biggs
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,

the integers in the arry are not zero, I think that I'm stuck in the loop and the executeBatch is not even reached.

How do i exit Enumeration after the last record? other wise I'll have to write the file string token into ArrayList and use a for/loop based on the ArrayList size.

I know this works but I rather use the Enumeration

RB
[ November 04, 2004: Message edited by: rastas biggs ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33713
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rastas,
The loop looks ok to me. What does the console show for the printlns in the loop? Does it execute a certain number of times or infinitely?

Just a note: Iterators are prefered over Enumerations. But that doesn't make a difference for the purposes of this discussion.
 
Bill Fences
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just the MSN value, i did have another println under the executeBatch and in never hits, mind you I am writing the values to a textfile adding them to the ArrayList, closing the Printer and then processsing the array to use the same connection, if that has any impact at all.

I use a for loop and did a allMSN.size() to limit the loop and it worked fine.

Bill c/o Rastas
[ November 05, 2004: Message edited by: Bill Fences ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic