0

I would like to ask on how to do calculations and saving the result and retrieve again just like making a deposit and withdrowal in banking system. i really dont know how to do so.. i am trying to formulate some codes but it just don't work. Pls help. I am using netbeans and sqlite as my database!

3
Contributors
3
Replies
20
Views
4 Years
Discussion Span
Last Post by IIM
0

I HAve this code.. and I want to subtract a current value in my program which is the loadamount from a VALUE in my database which is balance. And put rem as the result of it and as a new value for balance.

double rem=0; String bal; double getbal;

    try
{
    Class.forName("org.sqlite.JDBC").newInstance();
    conn = DriverManager.getConnection("jdbc:sqlite:E:\\OfficialJAVA\\data.sqlite");
    String data = "select * from userinfo where username =? and balance=? ";

    ps = conn.prepareStatement(data);
    ps.setString(1, n);
    rs = ps.executeQuery();
    if (rs.next()) {
        bal = rs.getString("balance");
        getbal=Double.parseDouble(bal);
       l= Double.parseDouble(txloadsrp.getText());
       rem= getbal-l;   
       }
    }catch(Exception e)
    {
    JOptionPane.showMessageDialog(null, e);
    }

Edited by zdneth

0

your question is not clear.What exactly do you want to do ?What error you are getting?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.