NetBeans and SQLite error
Hi everybody
I've spent a good portion of an hour trying to figure out my mistake.
I am continuously getting a "no such table error".
I have two classes. The one offers the connection, which works fine.
The other signs in. I have used a tutorial from YouTube and followed it in detail...
This is where the error comes up. Specifically, the bold part.
----
private void entryButtonActionPerformed(java.awt.event.ActionEv ent evt) {
String sql = "select * from CoachInfo where Username=? and Password=?";
try {
pst = conn.prepareStatement(sql);
pst.setString(1, usernameField.getText());
pst.setString(2, passwordField.getText());
rs = pst.executeQuery();
if (rs.next()) {
JOptionPane.showMessageDialog(null, "Username and Password are correct.");
CoachOptions s = new CoachOptions();
s.setVisible(true);
} else {
JOptionPane.showMessageDialog(null, "Username and/or Password incorrect.");
}
} catch (SQLException ex) {
Logger.getLogger(SignIn.class.getName()).log(Level .SEVERE, null, ex);
}
}
The error is:
Oct 13, 2012 8:55:21 PM SignIn entryButtonActionPerformed
SEVERE: null
java.sql.SQLException: no such table: CoachInfo
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 SignIn.entryButtonActionPerformed(SignIn.java:181)
at SignIn.access$300(SignIn.java:17)
at SignIn$4.actionPerformed(SignIn.java:98)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.jav a:6382)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3275)
at java.awt.Component.processEvent(Component.java:614 7)
at java.awt.Container.processEvent(Container.java:208 3)
at java.awt.Component.dispatchEventImpl(Component.jav a:4744)
at java.awt.Container.dispatchEventImpl(Container.jav a:2141)
at java.awt.Component.dispatchEvent(Component.java:45 72)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4619)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4280)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4210)
at java.awt.Container.dispatchEventImpl(Container.jav a:2127)
at java.awt.Window.dispatchEventImpl(Window.java:2489 )
at java.awt.Component.dispatchEvent(Component.java:45 72)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:704)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:663)
at java.awt.EventQueue$2.run(EventQueue.java:661)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:677)
at java.awt.EventQueue$3.run(EventQueue.java:675)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 674)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
-----
Any help would be greatly appreciated...
Ari
Re: NetBeans and SQLite error
Thread moved from What's wrong with my code.
The Exception message is pretty clear...you don't have a table named CoachInfo in the database the program is connected to. Make sure you have selected the appropriate database (and if relevant schema), and that this database contains the appropriate tables.
Re: NetBeans and SQLite error
Quote:
Originally Posted by
copeg
Thread moved from What's wrong with my code.
The Exception message is pretty clear...you don't have a table named CoachInfo in the database the program is connected to. Make sure you have selected the appropriate database (and if relevant schema), and that this database contains the appropriate tables.
Hi. Sorry about placing my thread in the wrong location.
This is precisely my issue. I open the database and the table is indeed there... And I've tried with the other tables in the database and still I reach the same conclusion...
Re: NetBeans and SQLite error
Got it fixed. Thank everybody. My location was formatted as Windows, and I'm working on a Mac ("/" instead of "\\"). Thanks!