java - SQL error or missing database(no such table:Employeeinfo) using sqlite and net beans -


this project in systems analysis , design class, new java, have taken basic course, , databases,never taken course. first time posting on site, apologize if code format little messy.

here code class load db.

import java.sql.*; import javax.swing.*; public class javaconnect { connection conn=null;  public static connection connecrdb() {     try{         class.forname("org.sqlite.jdbc").newinstance();         connection        conn=drivermanager.getconnection         ("jdbc:sqlite:macintosh hd\\users\\matthewslauson\\documents\\workspace\\schedulesystem.sqlite" );         joptionpane.showmessagedialog(null, "connection successful");         return conn;     }catch(exception e)         {         joptionpane.showmessagedialog(null, e);             return null;         }     } } 

the connection database works fine, when try input username , password error. here code login screen. assure table employeeinfo exist in schedulesystem.sqlite.

    import java.sql.*;     import javax.swing.*;      public class newjframe extends javax.swing.jframe {     connection conn=null;     resultset rs =null;     preparedstatement pst=null;  /**  * creates new form newjframe  */ public newjframe() {     initcomponents();     conn=javaconnect.connecrdb(); }  /**  * method called within constructor initialize form.  * warning: not modify code. content of method  * regenerated form editor.  */ @suppresswarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="generated code">                           private void initcomponents() {      jpanel1 = new javax.swing.jpanel();     txtusername = new javax.swing.jtextfield();     txtpassword = new javax.swing.jpasswordfield();     btnlogin = new javax.swing.jbutton();     jlabel1 = new javax.swing.jlabel();      setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close);      txtusername.addactionlistener(new java.awt.event.actionlistener() {         public void actionperformed(java.awt.event.actionevent evt) {             txtusernameactionperformed(evt);         }     });      txtpassword.settext("jpasswordfield1");      btnlogin.settext("login");     btnlogin.addactionlistener(new java.awt.event.actionlistener() {         public void actionperformed(java.awt.event.actionevent evt) {             btnloginactionperformed(evt);         }     });      jlabel1.setfont(new java.awt.font("sinhala sangam mn", 1, 36)); // noi18n     jlabel1.settext("welcome");      javax.swing.grouplayout jpanel1layout = new javax.swing.grouplayout(jpanel1);     jpanel1.setlayout(jpanel1layout);     jpanel1layout.sethorizontalgroup(         jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading)         .addgroup(jpanel1layout.createsequentialgroup()             .addgap(151, 151, 151)             .addcomponent(btnlogin)             .addcontainergap(javax.swing.grouplayout.default_size, short.max_value))         .addgroup(javax.swing.grouplayout.alignment.trailing, jpanel1layout.createsequentialgroup()             .addcontainergap(128, short.max_value)             .addgroup(jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading)                 .addgroup(javax.swing.grouplayout.alignment.trailing, jpanel1layout.createsequentialgroup()                     .addgroup(jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading)                         .addcomponent(txtpassword, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size)                         .addcomponent(txtusername, javax.swing.grouplayout.preferred_size, 120, javax.swing.grouplayout.preferred_size))                     .addgap(128, 128, 128))                 .addgroup(javax.swing.grouplayout.alignment.trailing, jpanel1layout.createsequentialgroup()                     .addcomponent(jlabel1)                     .addgap(117, 117, 117))))     );     jpanel1layout.setverticalgroup(         jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading)         .addgroup(jpanel1layout.createsequentialgroup()             .addgap(36, 36, 36)             .addcomponent(jlabel1)             .addgap(32, 32, 32)             .addcomponent(txtusername, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size)             .addgap(18, 18, 18)             .addcomponent(txtpassword, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size)             .addgap(18, 18, 18)             .addcomponent(btnlogin)             .addcontainergap(61, short.max_value))     );      javax.swing.grouplayout layout = new javax.swing.grouplayout(getcontentpane());     getcontentpane().setlayout(layout);     layout.sethorizontalgroup(         layout.createparallelgroup(javax.swing.grouplayout.alignment.leading)         .addcomponent(jpanel1, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, short.max_value)     );     layout.setverticalgroup(         layout.createparallelgroup(javax.swing.grouplayout.alignment.leading)         .addcomponent(jpanel1, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, short.max_value)     );      pack(); }// </editor-fold>                          private void txtusernameactionperformed(java.awt.event.actionevent evt) {                                                 // todo add handling code here: }                                             private void btnloginactionperformed(java.awt.event.actionevent evt) {                                              // todo add handling code here:     string sql ="select * employeeinfo uname=? , pword=?";     try{         pst=conn.preparestatement(sql);                     pst.setstring(1, txtusername.gettext());                      pst.setstring(2, txtpassword.gettext());                       rs=pst.executequery();                      if(rs.next()){                          joptionpane.showmessagedialog(null, "login credentials valid");                       }                      else{                          joptionpane.showmessagedialog(null, "login credentials invalid");                      }     }catch(exception e)         {         joptionpane.showmessagedialog(null, e);             joptionpane.showmessagedialog(null, e);         }    }                                          /**  * @param args command line arguments  */ public static void main(string args[]) {     /* set nimbus , feel */     //<editor-fold defaultstate="collapsed" desc=" , feel setting code (optional) ">     /* if nimbus (introduced in java se 6) not available, stay default , feel.      * details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html       */     try {         (javax.swing.uimanager.lookandfeelinfo info : javax.swing.uimanager.getinstalledlookandfeels()) {             if ("nimbus".equals(info.getname())) {                 javax.swing.uimanager.setlookandfeel(info.getclassname());                 break;             }         }     } catch (classnotfoundexception ex) {         java.util.logging.logger.getlogger(newjframe.class.getname()).log(java.util.logging.level.severe, null, ex);     } catch (instantiationexception ex) {         java.util.logging.logger.getlogger(newjframe.class.getname()).log(java.util.logging.level.severe, null, ex);     } catch (illegalaccessexception ex) {         java.util.logging.logger.getlogger(newjframe.class.getname()).log(java.util.logging.level.severe, null, ex);     } catch (javax.swing.unsupportedlookandfeelexception ex) {         java.util.logging.logger.getlogger(newjframe.class.getname()).log(java.util.logging.level.severe, null, ex);     }     //</editor-fold>      /* create , display form */     java.awt.eventqueue.invokelater(new runnable() {         public void run() {             new newjframe().setvisible(true);         }     }); }  // variables declaration - not modify                      private javax.swing.jbutton btnlogin; private javax.swing.jlabel jlabel1; private javax.swing.jpanel jpanel1; private javax.swing.jpasswordfield txtpassword; private javax.swing.jtextfield txtusername; // end of variables declaration                    } 

this first time posting on website, apologize if code little messy.

i not sure if similar in sqlite, in postgresql, have prefix table name schema. ex: schema_name.employeeinfo


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -