This week's book giveaways are in the Cloud/Virtualization and Go forums.
We're giving away four copies each of Cloud Native Transformation: Practical Patterns for Innovation and The Go Workshop and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native Transformation: Practical Patterns for InnovationE this week in the Cloud/Virtualization forum
or The Go Workshop in the Go forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Multiple preparedStatements 1 Connection

 
Ranch Hand
Posts: 41
  • 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.


 
author & internet detective
Posts: 39756
797
Eclipse IDE VI Editor Java
  • 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
  • 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
Posts: 39756
797
Eclipse IDE VI Editor Java
  • 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.
 
Greenhorn
Posts: 9
  • 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 ]
 
CLUCK LIKE A CHICKEN! Now look at this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!