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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:47:38+00:00 2026-05-18T20:47:38+00:00

now I got some trouble connecting to my database. I know the tables i

  • 0

now I got some trouble connecting to my database. I know the tables i am looking for exist because when I access them with the command line they can be queried.

Probably some minor oversight but I would love some help.

This is where I make my connection to my database
package persistence;

import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;


public class DBRegistry {

    private static DBRegistry db = null;
    private static Connection connection = null;

    private DBRegistry() {};

    public static synchronized DBRegistry getUniqueInstance() {
        if (db == null) {
                db = new DBRegistry();
                return db;
        }
        else return db;
    }

    public synchronized Connection getDBConnection() {
            try {
                Class.forName("org.sqlite.JDBC");
                connection = DriverManager.getConnection("jdbc:sqlite:src/database/taskMan.db");
                return connection;
            } 
            catch (SQLException e) {e.printStackTrace();} 
            catch (ClassNotFoundException e) {e.printStackTrace();}
            return null;
    }

    public synchronized void closeConnection() {
        try {
            connection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

Here is how I query it

public void create(UUID oid, Object obj) {
    Task t = (Task)obj;
    String statement = "INSERT INTO `complexTask` (`oid`,`description`,`status`) VALUES (?, ?, ?)";
    try {
        PreparedStatement dbStatement = db.prepareStatement(statement);
        dbStatement.setString(1, oid.toString());
        dbStatement.setString(2, t.getDescription());
        dbStatement.setBoolean(3, t.getStatus());
        dbStatement.executeUpdate();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

and finally a stack trace:

java.sql.SQLException: no such table: complexTask
    at org.sqlite.DB.throwex(DB.java:288)
    at org.sqlite.NativeDB.prepare(Native Method)
    at org.sqlite.DB.prepare(DB.java:114)
    at org.sqlite.PrepStmt.<init>(PrepStmt.java:37)
    at org.sqlite.Conn.prepareStatement(Conn.java:231)
    at org.sqlite.Conn.prepareStatement(Conn.java:224)
    at org.sqlite.Conn.prepareStatement(Conn.java:213)
    at persistence.framework.ComplexTaskRDBMapper.create(ComplexTaskRDBMapper.java:23)
    at persistence.PersistanceFacade.create(PersistanceFacade.java:49)
    at persistence.persistanceStates.NewState.commit(NewState.java:10)
    at persistence.PersistentObject.commit(PersistentObject.java:23)
    at domain.objects.Task.commitToDB(Task.java:89)
    at domain.TaskRepository.commitToDB(TaskRepository.java:60)
    at domain.TaskController.persistanceCommit(TaskController.java:97)
    at presentation.TaskControlsJPanel$3.actionPerformed(TaskControlsJPanel.java:127)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:253)
    at java.awt.Component.processMouseEvent(Component.java:6175)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:5940)
    at java.awt.Container.processEvent(Container.java:2105)
    at java.awt.Component.dispatchEventImpl(Component.java:4536)
    at java.awt.Container.dispatchEventImpl(Container.java:2163)
    at java.awt.Component.dispatchEvent(Component.java:4362)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4125)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4055)
    at java.awt.Container.dispatchEventImpl(Container.java:2149)
    at java.awt.Window.dispatchEventImpl(Window.java:2478)
    at java.awt.Component.dispatchEvent(Component.java:4362)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:604)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

And some JUnit code for good measure, the first test passes and the second fails with a similar error to the one above

package test.persistence;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import persistence.DBRegistry;
import junit.framework.TestCase;

public class TestDBRegistry extends TestCase {

    public void testDBRegistryConnection() {
        Connection con =  DBRegistry.getUniqueInstance().getDBConnection();
        assertNotNull(con);
    }

    public void testTableQuery() throws SQLException {
        Connection con =  DBRegistry.getUniqueInstance().getDBConnection();
        PreparedStatement dbStatement = con.prepareStatement("SELECT COUNT(*) FROM `singleTask`");
        assertEquals("should be 1 for successful query", 1, dbStatement.executeQuery());
    }
  • 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-18T20:47:39+00:00Added an answer on May 18, 2026 at 8:47 pm

    I notice that in both your unit test and your other code you are using back-ticks around the table name. In the latest version of sqlite, this is fine but in older versions it wasn’t handled as well I believe. Can you try removing the ticks around the table name or maybe changing them to regular quotes rather than back-ticks?

    If that doesn’t solve it I would check to be absolutely sure that you are pointing to the correct db file. If you specify a filename that doesn’t exist you won’t get an error, it will simply create a new database there. I’m not sure what the “current directory” is under the context of your app or unit test but be sure it is pointing to where you think it is. To test this, you could change the db file name to foo.db, run the unit test, then search your machine for foo.db to see where it got created. That will tell you where your app is working off of.

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

Sidebar

Related Questions

I got some code off the Internet and now I just need help to
I've got some numbers that is now larger than INT can handle. This is
I just started to learn about mod rewrite process. Now, I got some problems
i have done some learning on struts based on one project that i got.Now
I've got a WinForms project that I've had for quite some time, and now
i got some trouble to understand scope in OOP. What i want is that
I've got some trouble in understanding the following behavior. I'm having a container <div>
While I was playing with Air Sqlite, I got some trouble in saving Date
I got in the trouble i am making some packages in my application all
I'm having some trouble with MySql right now. I have an query that works

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.