Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6594399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:48:21+00:00 2026-05-25T17:48:21+00:00

I wrote an application that inserts some data in a SQlite database using JDBC

  • 0

I wrote an application that inserts some data in a SQlite database using JDBC and have the ability of Read/Update that data.
The problem is when i change data by application it updates data and while program is open reading those data gives new (updated) data.
But when I exit the program and re-run it all of those changes are lost and data is reset to when program opened for the first time!
I connect like this:

Class.forName("org.sqlite.JDBC");
con=DriverManager.getConnection("jdbc:sqlite:archive.sqlite");

and then update four tables like this:

try{
    String Q="UPDATE data SET startdate=?,fazelab=?,length=?,maliat=?,other=?,price=?,public=?,usage=?,abbaha=?,enddate=? WHERE id='"+ID+"'";
    PreparedStatement PS= this.con.prepareStatement(Q);
    PS.setString(1, (String)data.get("startdate"));
    PS.setInt(2, (Integer)data.get("fazelab"));
    PS.setInt(3, (Integer)data.get("length"));
    PS.setInt(4, (Integer)data.get("maliat"));
    if(data.containsKey("other"))
        PS.setInt(5, (Integer)data.get("other"));
    else
        PS.setInt(5, 0);
    PS.setLong(6, (Long)data.get("price"));
    PS.setDouble(7, (Double)data.get("public"));
    PS.setInt(8, (Integer)data.get("usage"));
    PS.setInt(9, (Integer)data.get("abbaha"));
    PS.setString(10, (String)data.get("enddate"));
    COUNT=PS.executeUpdate();

    Q="UPDATE cold SET cE1=?,cW1=?,cE2=?,cW2=?,cE3=?,cW3=?,cE4=?,cW4=? WHERE dataid='"+ID+"'";
    PS= this.con.prepareStatement(Q);
    PS.setDouble(1, cold.get("cE1"));
    PS.setDouble(2, cold.get("cW1"));
    PS.setDouble(3, cold.get("cE2"));
    PS.setDouble(4, cold.get("cW2"));
    PS.setDouble(5, cold.get("cE3"));
    PS.setDouble(6, cold.get("cW3"));
    PS.setDouble(7, cold.get("cE4"));
    PS.setDouble(8, cold.get("cW4"));
    COUNT+=PS.executeUpdate();

    Q="UPDATE hot SET hE1=?,hW1=?,hE2=?,hW2=?,hE3=?,hW3=?,hE4=?,hW4=? WHERE dataid='"+ID+"'";
    PS= this.con.prepareStatement(Q);
    PS.setDouble(1, hot.get("hE1"));
    PS.setDouble(2, hot.get("hW1"));
    PS.setDouble(3, hot.get("hE2"));
    PS.setDouble(4, hot.get("hW2"));
    PS.setDouble(5, hot.get("hE3"));
    PS.setDouble(6, hot.get("hW3"));
    PS.setDouble(7, hot.get("hE4"));
    PS.setDouble(8, hot.get("hW4"));
    COUNT+=PS.executeUpdate();

    Q="UPDATE usages SET E1=?,W1=?,E2=?,W2=?,E3=?,W3=?,E4=?,W4=? WHERE dataid='"+ID+"'";
    PS= this.con.prepareStatement(Q);
    PS.setDouble(1, USGs.get("E1"));
    PS.setDouble(2, USGs.get("W1"));
    PS.setDouble(3, USGs.get("E2"));
    PS.setDouble(4, USGs.get("W2"));
    PS.setDouble(5, USGs.get("E3"));
    PS.setDouble(6, USGs.get("W3"));
    PS.setDouble(7, USGs.get("E4"));
    PS.setDouble(8, USGs.get("W4"));
    COUNT+=PS.executeUpdate();

    PS.close();
}finally{
    return COUNT;
}

What is the problem?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:48:22+00:00Added an answer on May 25, 2026 at 5:48 pm

    There are three points you should check:

    • are all resources like PreparedStatement, ResultSet etc. closed before issuing the next statements? Also close the Connection properly at the end.

    • What is your autocommit status? Check it on Connection with getAutoCommit(). If it is false, you must issue a Connection.commit() by hand. This is a setting which varies between databases is is most often omitted by error.

    • Check the setup of the database itself: sqlite is an embedded database and sometimes these have strange configuration defaults for easy startup or unit-testing. For example: “start me in memory only” or “truncate all table at startup”. Don’t laugh, I have seen things like that!
      Check the Documentation for that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with JDBC application that uses MONEY data type. When I insert
I have wrote an application that syncs two folders together. The problem with the
I have a Windows Forms application that I wrote that does some monitoring of
I have got a Wavecom Supreme GSM modem. I wrote a simple application that
I have a process that currently runs in a Delphi application that I wrote
I could use some suggestions / ideas. I wrote a console application that queries
I have written a application that parses the html code of some web pages.
I've just started using SQLite and I want to write all my application data
Hallo, I am writing a database application that does a lot of inserts and
In my application, I am using an AsyncTask to write some data to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.