3 Replies - 777 Views - Last Post: 28 June 2015 - 08:56 AM Rate Topic: -----

#1 rohtashrathore   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 11-June 15

manipulating the database by user input values in swing

Posted 28 June 2015 - 07:50 AM

Hi All,
I want to update my table in my sql(admin),here in this table we are having column name quantity,now when user input the value in the input field called stock ,As he release the mouse we will set text of available quantity,if available,now my question is how we will impliment this,i have the text variable name stock_text.getText(),'i have did some thing like this ,is it correct?It is not working properly i am not able to to use userinput2 which is my sql database value for a particular row,




 double userinput2;
   userinput2=select quantity from itemdetails where itemcode=?;
      double balancequantity=userinput2-Double.parseDouble(stock_text.getText());
  sql="  update itemdetails set quantity= balancequantity WHERE itemcode=?";



Is This A Good Question/Topic? 0
  • +

Replies To: manipulating the database by user input values in swing

#2 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12315
  • View blog
  • Posts: 45,414
  • Joined: 27-December 08

Re: manipulating the database by user input values in swing

Posted 28 June 2015 - 08:07 AM

Quote

As he release the mouse we will set text of available quantity

So there are two important factors. First is the GUI, and the second is the database. These pieces of functionality should be separate. I'd look at the MVC pattern as a starting point.

From the GUI side, I would imagine a Listener of some sorts such as an ActionListener could be used. Have a submit JButton. When it's clicked, a separate component should be responsible for querying the database (not your GUI code).

Quote

'i have did some thing like this ,is it correct?It is not working properly

It seems you answered your own question. Your code won't even compile.
Was This Post Helpful? 0
  • +
  • -

#3 rohtashrathore   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 11-June 15

Re: manipulating the database by user input values in swing

Posted 28 June 2015 - 08:51 AM

OK I.will add some kind of listener sir and I already used MVC pattern now how would I do code there for this .....do u have any code dummy code which represent it
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12315
  • View blog
  • Posts: 45,414
  • Joined: 27-December 08

Re: manipulating the database by user input values in swing

Posted 28 June 2015 - 08:56 AM

There are a ton of basic Java GUI tutorials you can check out.

There are a plethora of java tutorials regarding GUI apps.
http://www.dreaminco...c-gui-concepts/
http://www.dreaminco...-for-beginners/
http://www.dreaminco...-using-jframes/
http://www.dreaminco...c-gui-concepts/
http://www.dreaminco...torial-in-java/

http://www.dreaminco...ad-application/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1