Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,593 members, 7,809,149 topics. Date: Friday, 26 April 2024 at 01:26 AM

Please I Need Help On This Little Problem - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Please I Need Help On This Little Problem (984 Views)

Check Out This Little App I Made With React / Please I Need Help On This Little Problem / Java Gurus Please I Need This Little Assignment Solved ''appreciation Involved" (2) (3) (4)

(1) (Reply)

Please I Need Help On This Little Problem by ibroauthen(m): 8:43am On Apr 15, 2018
Hello my ogas at the top. I am just learning Java programming language and I have a project on medical store that I am working on but I have a little problem.
I created a button and I want the button to deduct the number of drugs order through a jtextfield but when ever I press the button it only places order but won't deduct any value from the db.
This is the code I used.

String val=jLabel5.getText();
String val1=Jtextfield5.getText();
int val2= Integer.parseInt(val1);

try{
String sql=" update druginfo set qty ='" +val1+"' where id='" +val+"' " ;
pst=conn.PrepareStatement(sql):
rst=pst.executeUpdate();

while(rst.next()) {
String add=rst.getInt("qty"wink;

}
add-val2;

} catch(Exception e) {
JOptionPane.showMessageDialog(null, e);
}

But the code is not getting the job done. Please help a brother in need I have searched Google and found no reasonable answer.
Re: Please I Need Help On This Little Problem by jeffreyUzo: 9:24am On Apr 16, 2018
you need to show the error log to be sure that something is wrong.

In the mean time, do the below if there are no error logs :

Get the actual {sql} query text that is formed in your code and run that directly on the database and see if it works normally. If it doesn't work then the issue you are having is with the query string that you are sending to the database.

Let us know if this works, you code is actually looking okay for a normal data connectivity statement.
Re: Please I Need Help On This Little Problem by Nobody: 9:14pm On Apr 16, 2018
ehmmmm you deducted the value in code and not in db, where you expecting the value to deduct without a sql to do that.

(1) (Reply)

Programmers Help:python Code To Acess Laptop/desktop Camera / I Need PHP Tutorial Materials, Someone Should Please Help Me / A Cheat-sheet For Password Crackers

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.