java - How to retrieve and/or add database table values and display in the textfield -


computehandler.java

public class computehandler extends dbcollection {     private int totalcapitalprice, totalprice;      public void settotalcapitalprice(int temp)     {         this.totalcapitalprice = temp;     }     public void settotalprice(int temp)     {         this.totalprice = temp;     }      public int gettotalcapitalprice()     {         return this.totalcapitalprice;     }     public int gettotalprice()     {         return this.totalprice;     } } 

where put

select sum(capital_price) item_list

and

select sum(price) item_list

i have class named dbcollection extends dbconnection , connects codes database...

dbcollection.java

public class dbcollection extends dbconnection{ private connection connect = null; private resultset rs = null; private statement stmt = null;  public dbcollection() {     try     {         connect = super.getconnection();         stmt = connect.createstatement();         //joptionpane.showmessagedialog(null,"connected!");      }     catch(exception ex)     {         //joptionpane.showmessagedialog(null,"not connected!");     } }  private void closeconnection() {     super.closeconnection(connect);     super.closerecordset(rs);     super.closestatement(stmt); } 

i want sum of saved capital_price , price values in database.. , retrieve capitalpricetf (textfield) , pricetf (textfield also).. how do that?

i want retrieve first_name of saved user... , display welcome(first name of user)..

you need execute query using statement object:

so statement object :

stmt = connect.createstatement(); 

execute queries :

rs = stmt.executequery("select sum(capital_price) sum item_list"); 

resultset rs object holds retrieved data query, can data like:

int sum = rs.getint("sum"); 

then have do, organize code based on above , every thing works fine.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -