i got a error using SQLiteQueue

247 views
Skip to first unread message

Amila Kumara

unread,
May 13, 2012, 2:30:20 PM5/13/12
to sqlit...@googlegroups.com
May 13, 2012 11:55:36 PM com.almworks.sqlite4java.Internal log
INFO: [sqlite] DB[1]: instantiated [data]
May 13, 2012 11:55:36 PM com.almworks.sqlite4java.Internal log
INFO: [sqlite] Internal: loaded sqlite4java-win32-x86 from D:\Java\Libs\sqlite4java\sqlite4java-win32-x86.dll
May 13, 2012 11:55:36 PM com.almworks.sqlite4java.Internal log
INFO: [sqlite] Internal: loaded sqlite 3.7.10, wrapper 0.2
May 13, 2012 11:55:36 PM com.almworks.sqlite4java.Internal log
INFO: [sqlite] DB[1]: opened
May 13, 2012 11:55:36 PM com.almworks.sqlite4java.Internal log
INFO: [sqlite] DB[2]: instantiated [data]
May 13, 2012 11:55:36 PM com.almworks.sqlite4java.Internal log
INFO: [sqlite] DB[2]: opened
May 13, 2012 11:55:36 PM com.almworks.sqlite4java.Internal log
INFO: [sqlite] DB[1]: connection closed
May 13, 2012 11:55:42 PM rentcar.DBSqlite sqlSearch
SEVERE: null
com.almworks.sqlite4java.SQLiteException: [-98] DB[2] confined(Thread[SQLiteQueue[data],5,]) used (Thread[AWT-EventQueue-0,6,main])
at com.almworks.sqlite4java.SQLiteConnection.checkThread(SQLiteConnection.java:1391)
at com.almworks.sqlite4java.SQLiteConnection.prepare(SQLiteConnection.java:451)
at com.almworks.sqlite4java.SQLiteConnection.prepare(SQLiteConnection.java:542)
at com.almworks.sqlite4java.SQLiteConnection.prepare(SQLiteConnection.java:529)
at rentcar.DBSqlite.sqlSearch(DBSqlite.java:97)
at rentcar.LoginMain.LoginActionPerformed(LoginMain.java:311)
at rentcar.LoginMain.PasswordKeyReleased(LoginMain.java:379)
at rentcar.LoginMain.access$400(LoginMain.java:27)
at rentcar.LoginMain$6.keyReleased(LoginMain.java:190)
at java.awt.Component.processKeyEvent(Component.java:6465)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2829)
at java.awt.Component.processEvent(Component.java:6281)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4860)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4686)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1908)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:752)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1017)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:889)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:717)
at java.awt.Component.dispatchEventImpl(Component.java:4730)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Window.dispatchEventImpl(Window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4686)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)



can any one help me?

Igor Sereda

unread,
May 13, 2012, 5:13:31 PM5/13/12
to sqlite4java
This error means that you have opened SQLiteConnection in one thread
(obviously, in SQLiteQueue), and try to use it in another.

Instead of trying to access it in the AWT thread, you need to wrap
your operation in SQLiteJob and pass it to SQLiteQueue.

Hope this helps!
Igor
> java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusMana ger.java:717)
> at java.awt.Component.dispatchEventImpl(Component.java:4730)
> at java.awt.Container.dispatchEventImpl(Container.java:2287)
> at java.awt.Window.dispatchEventImpl(Window.java:2713)
> at java.awt.Component.dispatchEvent(Component.java:4686)
> at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
> at java.awt.EventQueue.access$000(EventQueue.java:101)
> at java.awt.EventQueue$3.run(EventQueue.java:666)
> at java.awt.EventQueue$3.run(EventQueue.java:664)
> at java.security.AccessController.doPrivileged(Native Method)
> at
> java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.j ava:76)
> at
> java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.j ava:87)
> at java.awt.EventQueue$4.run(EventQueue.java:680)
> at java.awt.EventQueue$4.run(EventQueue.java:678)
> at java.security.AccessController.doPrivileged(Native Method)
> at
> java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.j ava:76)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
> at
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.jav a:211)
> at
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:1 28)
> at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.jav a:117)

Amila Kumara

unread,
May 14, 2012, 12:52:38 PM5/14/12
to sqlit...@googlegroups.com
private void startQ() {
        myQueue = new SQLiteQueue(new File("data"));
        Object complete = myQueue.execute(new SQLiteJob<Object>() {

            @Override
            protected Object job(SQLiteConnection connection) throws SQLiteException {
                // this method is called from database thread and passed the connection
                SQLiteStatement st = DBSqlite.sqlSearch("SELECT * FROM User");
                Vector v = new Vector();
                while (st.step()) {
                    v.add(st.columnString(0));
                }
                v.removeElement("AdminPass");
                Username.setModel(new DefaultComboBoxModel(v));
                st.dispose();
                return null;
            }
        });
        myQueue.start();
        try {
            myQueue.stop(true).join();
        } catch (InterruptedException ex) {
            Logger.getLogger(LoginMain.class.getName()).log(Level.SEVERE, null, ex);
        }
    }



i'm using this code to do it

if you can show me where i'm wrong ,i'm so great full to you
and thanks for helping me early

Igor Sereda

unread,
May 15, 2012, 6:14:56 AM5/15/12
to sqlit...@googlegroups.com
Dear Amila, 

Clearly the code that you've posted has no relation to the exception stack trace that you've posted earlier.

Please ask one of your colleagues around to review your code. The problem is that you're accessing SQLiteConnection without wrapping the access in SQLiteJob - but I cannot help you find how does that happen.

Good luck!
Igor

Amila Kumara

unread,
Jul 16, 2012, 2:44:12 PM7/16/12
to sqlit...@googlegroups.com


On Monday, May 14, 2012 10:22:38 PM UTC+5:30, Amila Kumara wrote:
private void startQ() {
        myQueue = new SQLiteQueue(new File("data"));
        Object complete = myQueue.execute(new SQLiteJob<Object>() {

            @Override
            protected Object job(SQLiteConnection connection) throws SQLiteException {
                // this method is called from database thread and passed the connection
                SQLiteStatement st = DBSqlite.sqlSearch("SELECT * FROM User");
                Vector v = new Vector();
                while (st.step()) {
                    v.add(st.columnString(0));
                }
                v.removeElement("AdminPass");
                Username.setModel(new DefaultComboBoxModel(v));
                st.dispose();
                return null;
            }
        });
        myQueue.start();
        try {
            myQueue.stop(true).join();
        } catch (InterruptedException ex) {
            Logger.getLogger(LoginMain.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

 
i found my error
its SQLiteStatement st = DBSqlite.sqlSearch("SELECT * FROM User");

and it must be 
SQLiteStatement st = connection.prepare("SELECT * FROM User");

as i didnt use the connection made itself and tried to use the one i created

thanks for helping me earlier dear Igor Sereda
Reply all
Reply to author
Forward
0 new messages