Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Db Update Question

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi FOlks,
More than a JDBC q, this is really a SQL question. I hope someone out there can help me..
I have a database table, say customers, with cus_number, cus_name, cus_birthdate and cus_ssn
Now, i get a flat file with the the cus_number and cus_ssn on it. Have a java program that reads it, and then I need to populate the ssn field if the cus_number is already in the database.
Also need to be able to ignore if a cus_number is not found. FYI, i'm using mysql on winnt and I already have the JDBC drivers installed and everything and I'm able to access the db from the java program..
What i really need is help in formatting the update statement to update only one field of the db without affecting the others AND on how to catch a not-found cus_number
Thanks !!
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about something like:
<code>
String query = "UPDATE Customers SET cus_ssn = " + (your 1st java variable as read in from file) + " WHERE cus_number = " + (your 2nd java variable as read in from file);
</code>
If the customer number is not already in the database, no update will take place. If it is, only the cus_ssn field will be updated.
Easy as that.

------------------
"One good thing about music - when it hits, you feel no pain"
Bob Marley
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic