Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 14th, 2004, 07:12 AM
abhit_kumar abhit_kumar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 22 abhit_kumar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 3 sec
Reputation Power: 0
updation prob..........

i have an jsp page which is used to update the two tables named
1) pay_header 2) pay_detail.

In which the values of chq_amt of table 1 should be equal to values of db_amt of table 2.

i have used the following query:

PreparedStatement pstatement = conn.prepareStatement(
"UPDATE pay_header,pay_detail SET pay_header.chq_amt=pay_detail.db_amt where pay_header.vou_no = pay_detail.vou_no");


pstatement.setFloat(1,Float.parseFloat(request.get Parameter("chq_amt")));
pstatement.setFloat(2,Float.parseFloat(request.get Parameter("db_amt")));
pstatement.setString(3,request.getParameter("vou_no"));

int rowCount = pstatement.executeUpdate();
conn.setAutoCommit(false);
conn.setAutoCommit(true);


its coming error

help

Reply With Quote
  #2  
Old December 14th, 2004, 09:05 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
What error are you getting?

Your query looks very complex and may be causing an error.
Have you tried running it directly against the DB to make sure it works?
Which values are parameters in your preparedstatement?

May I ask why you're setting AutoCommit twice at the end?

Reply With Quote
  #3  
Old December 20th, 2004, 06:57 AM
Bal Bal is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 1 Bal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation

Quote:
Originally Posted by abhit_kumar
i have an jsp page which is used to update the two tables named
1) pay_header 2) pay_detail.

In which the values of chq_amt of table 1 should be equal to values of db_amt of table 2.

i have used the following query:

PreparedStatement pstatement = conn.prepareStatement(
"UPDATE pay_header,pay_detail SET pay_header.chq_amt=pay_detail.db_amt where pay_header.vou_no = pay_detail.vou_no");


pstatement.setFloat(1,Float.parseFloat(request.get Parameter("chq_amt")));
pstatement.setFloat(2,Float.parseFloat(request.get Parameter("db_amt")));
pstatement.setString(3,request.getParameter("vou_no"));

int rowCount = pstatement.executeUpdate();
conn.setAutoCommit(false);
conn.setAutoCommit(true);


its coming error

help



Hi
jus a guess

for the below statements to work...
pstatement.setFloat(1,Float.parseFloat(request.getParameter("chq_amt")));
pstatement.setFloat(2,Float.parseFloat(request.getParameter("db_amt")));
pstatement.setString(3,request.getParameter("vou_no"));

The below statements needs to have three "?" to be substitued with 1,2,3 respectively. so instead of using chq_amt, db_amt
and vou_no directly use "?" in its place and then execute the setXXXX(...) statements.

PreparedStatement pstatement = conn.prepareStatement(
"UPDATE pay_header,pay_detail SET pay_header.chq_amt=pay_detail.db_amt where pay_header.vou_no = pay_detail.vou_no");


letmme know your comments on the same

Cheers
Bal

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > updation prob..........


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap