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 8259709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:55:39+00:00 2026-06-08T02:55:39+00:00

I am using a Java GUI program to update a SQlite database. My Gui

  • 0

I am using a Java GUI program to update a SQlite database. My Gui options are mostly toggle buttons with on/off values. Due to the nature of the Gui, performance in updating the database needs to be fast so control can be returned to the Gui calling function quickly.

I have the following code, which runs every time a toggle button is selected:

public static void updateDCStable(String item, int value)
{
    try {
        long start = System.currentTimeMillis();
        Class.forName("org.sqlite.JDBC");
        String url = DATABASE_FILEPATH; 
        Connection conn = DriverManager.getConnection(url);

        Statement update = conn.createStatement();           
        update.execute("UPDATE DCS "
                + "SET " + item + "='" + value + "';");

        update.close();
        conn.close();

        long time_elapsed = System.currentTimeMillis() - start;
        System.out.println("Changed DCS date item " + item + " to "
                + value + " in " + time_elapsed + "(ms)");
    } catch (SQLException ex) { /* Error handling */
    } catch (ClassNotFoundException ex) { /* Error handling */
    } 
}

My SQL table is basically configuration info with several columns and just one row, so the function takes the column and the update value and updates the item accordingly. The function works correctly, its just really slow….

Using the time elapsed, my average update time is running about 550 ms or so with a min time of 294 ms and a max time of 986 ms. Is there any way that I can speed up this process?

  • 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-06-08T02:55:40+00:00Added an answer on June 8, 2026 at 2:55 am

    It would be faster if you used a connection from a connection pool. You wouldn’t have to establish and close the connection each time you access the database, which takes a lot of the time.

    PreparedStatements mentioned by Pierre will also help, but the majority of the time spent on your database jobs is the estabilishing/releasing the database connection issues.

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

Sidebar

Related Questions

I'm trying to program my first GUI-class in Java, using the Window Builder. Ok,
I am creating a GUI using Java. This GUI launches a program from the
I`m making a GUI for my java program using Swing Components and Netbeans IDE.
I am using netbeans IDE to develop a GUI for a java program. I
I am using Java Netbeans GUI Builder for making GUI. I want to give
I am using a Java JMS GUI utility (HermesJMS), and in its runtime, I
I am trying to create a GUI using java swing. From there I have
I'm trying to create a GUI using Java by hand-coding it (without using GUI
I am making a GUI of Stack using Java. Here is my code private
I am trying to create my first GUI application using (Java + Eclipse +

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.