Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Update table in database

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Update table in database

    Hi, I have a problem about update table in a database. The situation is I have a table named member which store thousand rows of data records about thousand of member for a system. This member table has a field named MemberExpiryDate which used to store each member expired date. I have been asked to update the data records for member with member expired date equals to '2011/05/01'. So, as I count there are 50 of records (which member expired date is '2011/05/01') out of thousand of records in that member table need to be update. So, I write a Java program to update those 50 data records and the program is run without prompt out any error. But I have a question is how can I confirm that those 50 records out of thousand of records are updated completely and how can I confirm that other data except those 50 records are not affected and not updated ? Is it got any function in Java can let me know which record from those 50 records is not update exactly ? Is it got any method can let me know other data records except those 50 records are not affected ?

    Thanks


  2. #2
    Member DanBrown's Avatar
    Join Date
    Jan 2011
    Posts
    134
    My Mood
    Confused
    Thanks
    1
    Thanked 12 Times in 12 Posts

    Default Re: Update table in database

    My suggestion is you can first fetch records matched that criteria and show those record to user and after that perform the
    update operation, when you will call sql update query it will return you no of record affected.
    Now you can compare with no of records fetched earlier and got affected.

    Even you can also show updated records to user.
    Thanks and Regards
    Dan Brown

    Common Java Mistakes

  3. The Following User Says Thank You to DanBrown For This Useful Post:

    CTheSky (January 29th, 2011)

  4. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Update table in database

    Cross posted at Update table in database - Java Forums While cross posting is not against the rules of this forum, it is recommended you post links to other locations your question was asked. For the reasoning behind this, see The problems with crossposting

  5. #4
    Junior Member
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Update table in database

    Thanks for your help. I will try it .

  6. #5
    Junior Member
    Join Date
    Feb 2011
    Location
    Kochi,India
    Posts
    18
    My Mood
    Confused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Update table in database

    Quote Originally Posted by CTheSky View Post
    Hi, I have a problem about update table in a database. The situation is I have a table named member which store thousand rows of data records about thousand of member for a system. This member table has a field named MemberExpiryDate which used to store each member expired date. I have been asked to update the data records for member with member expired date equals to '2011/05/01'. So, as I count there are 50 of records (which member expired date is '2011/05/01') out of thousand of records in that member table need to be update. So, I write a Java program to update those 50 data records and the program is run without prompt out any error. But I have a question is how can I confirm that those 50 records out of thousand of records are updated completely and how can I confirm that other data except those 50 records are not affected and not updated ? Is it got any function in Java can let me know which record from those 50 records is not update exactly ? Is it got any method can let me know other data records except those 50 records are not affected ?

    Thanks
    It is not clear whether this updation requires any user input. I assume that your program has the values that are to be updated to these 50 records. Your problem is to find out how many rows are updated. There is no built in function for this as far as i know. you could place a counter in your program which will get incremented for each updates. You can easily tune this for getting the no. of rows that are not updated also.

    Hope it answer your query. Cheers

Similar Threads

  1. Cannot update data in .txt/.csv file
    By Azriq007 in forum JDBC & Databases
    Replies: 2
    Last Post: October 16th, 2010, 09:16 PM
  2. how to import excel file to database table using java
    By palani in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: September 3rd, 2010, 12:17 AM
  3. Replies: 0
    Last Post: April 15th, 2010, 05:13 AM
  4. Replies: 0
    Last Post: January 26th, 2010, 04:10 PM