Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-14-2008, 10:32 AM
Member
 
Join Date: Apr 2008
Posts: 2
kvikas is on a distinguished road
ResultSet.updateRow() problem
Hi All,
I'm using MS Access DB. I want to trim the data in the table named 'Sold'. I'm getting correct resultset with all rows from table 'Sold'. When i iterate over resultset and tries to update the column value after trimming, only first row gets updated correctly with trimming. Unexpected results occurred from second row. It fetches empty string or string with characters omitted from right if i places leading spaces to the column value in DB.
*empName is the only column in the table 'Sold'. Whose type is 'Text'.

Heres the code,

public void trimDataRows(){
ResultSet rs=null;
int updateCount=0;
String empNo=null, empName=null, tempName=null, checkedFlag=null;
try{
rs=stmt.executeQuery("select * from Sold");

rs.last();
int rowCount=rs.getRow(); //Nomber of rows in resultset.
System.out.println("Count "+rowCount);

for(int i=1; i<=rowCount; ++i){

rs.absolute(i);
empName=rs.getString(1);
System.out.println("Old: "+rs.getString(1)+"& "+empName.length());
tempName=empName.trim();
System.out.println("New: "+tempName+"& "+tempName.length());
rs.updateString(1, tempName);
rs.updateRow();
updateCount++;
}
rs.close();
stmt.close();
con.close();


}catch(Exception e){ e.printStackTrace();}
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-22-2008, 04:11 AM
Member
 
Join Date: Apr 2008
Posts: 28
rico16135 is on a distinguished road
while(rs.next() ) {
//stuff todo
}

Not clear exactly what your prob is
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with ResultSet.updateRow() kvikas New To Java 0 04-14-2008 11:00 AM
ResultSet to XML Java Tip Java Tips 0 02-14-2008 10:50 AM
ResultSet to HTML Java Tip Java Tips 0 02-12-2008 10:32 AM
ResultSet to JTable Java Tip Java Tips 0 02-11-2008 10:01 AM
ResultSet example Java Tip Java Tips 0 01-20-2008 09:59 AM


All times are GMT +3. The time now is 09:53 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org