Results 1 to 2 of 2
  1. #1
    OldSkooFoo is offline Member
    Join Date
    Dec 2013
    Location
    Benicia
    Posts
    2
    Rep Power
    0

    Exclamation Unknown column 'New_Used' in 'field list'

    When I try to run my program in netbeans IDE i get the error "Unknown column 'New_Used' in 'field list'" and I use MySql workbench to handle the database. I added the field to the application after creating the column in the "nebas" table and I am getting that error. I have posted my code of the first error on a list of errors when running the application in netbeans IDE

    Java Code:
     
    
    public static void gtDB() throws ClassNotFoundException, SQLException {
    
            Statement s1 = DBConnect.connection.createStatement();
    
            // Get Record Count
            String selTable1 = "SELECT COUNT(*) AS total FROM " + StFrmNm;
            s1.execute(selTable1);
            ResultSet rs1 = s1.getResultSet();
            rs1.next();
            cnt = rs1.getInt("total");
            //System.out.println("Total Record Count: " + cnt);
            rs1.close();
    
            for (int w = 1; w < cnt + 1; w++) {
                cntRec = cntRec + 1;
                String selTable3 = "SELECT SKU AS rslt, Qty As rslt2, Description1 As rslt3, Orig_SKU As rslt4, "
                        + " Description2 As rslt5, Orig_Retail As rslt6, New_Used As rslt7, Reason As rslt8, "
                        + " Desc_Damage As rslt9, Ln_Date As rslt10 "
                        + "FROM " + StFrmNm + " WHERE Line = " + w;
                s1.execute(selTable3);
                ResultSet rs3 = s1.getResultSet();
                rs3.next();
                String sku = rs3.getString("rslt");
                String qty = rs3.getString("rslt2");
                String descr1 = rs3.getString("rslt3");
                String orgSku = rs3.getString("rslt4");
                String descr2 = rs3.getString("rslt5");
                String orgrt = rs3.getString("rslt6");
                String nwusd = rs3.getString("rslt7");
                String reas = rs3.getString("rslt8");
                String ddamg = rs3.getString("rslt9");
                String lndate = rs3.getString("rslt10");
                
                rs3.close();
    
                recLine[w] = sku + ";" + qty + "; " + descr1 + ";" + orgSku + ";" + descr2 + ";" + orgrt + ";" + nwusd + ";" + reas + ";" + ddamg + ";" + lndate + ";";
    
                //System.out.println(sku + ";" + qty + "; "+ descr1 + ";" + reas + ";" + ddamg + ";" + orgSku + ";" + orgrt + ";" + lndate);
            }
            s1.close();
    }
    Java Code:
     // Fill Lines w/Existing Data
            if (NEBASdao.cntRec > 0 && Character.isDigit(NEBASdao.recLine[1].split(";")[0].charAt(0))) {
                l1_1.setText(NEBASdao.recLine[1].split(";")[0]);
                l1_2.setText(NEBASdao.recLine[1].split(";")[1]);
                l1_3.setText(NEBASdao.recLine[1].split(";")[2]);
                l1_4.setText(NEBASdao.recLine[1].split(";")[3]);
                l1_5.setText(NEBASdao.recLine[1].split(";")[4]);
                l1_6.setText(NEBASdao.recLine[1].split(";")[5]);
                l1_7.setSelectedItem(NEBASdao.recLine[1].split(";")[6]);
                l1_8.setSelectedItem(NEBASdao.recLine[1].split(";")[7]);
                l1_9.setText (NEBASdao.recLine[1].split(";")[8]);
                l1_11.setText(NEBASdao.recLine[1].split(";")[9]);
                l1_10.setSelected(true);
                
                l1_1.setEnabled(false);
                l1_2.setEnabled(false);
                l1_3.setEnabled(false);
                l1_4.setEnabled(false);
                l1_5.setEnabled(false);
                l1_6.setEnabled(false);
                l1_7.setEnabled(false);
                l1_8.setEnabled(false);
                l1_9.setEnabled(false);




    Java Code:
    Dec 12, 2013 10:49:18 AM form_port_app.NEBAS <init>
    SEVERE: null
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'New_Used' in 'field list'
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    	at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    	at com.mysql.jdbc.Util.getInstance(Util.java:386)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
    	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
    	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
    	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2809)
    	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2758)
    	at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:894)
    	at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:732)
    	at form_port_app.NEBASdao.gtDB(NEBASdao.java:224)
    	at form_port_app.NEBASdao.ChkForm(NEBASdao.java:99)
    	at form_port_app.NEBAS.<init>(NEBAS.java:77)
    	at form_port_app.NEBAS$38.run(NEBAS.java:2856)
    	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)
    	at java.awt.EventQueue.access$200(EventQueue.java:103)
    	at java.awt.EventQueue$3.run(EventQueue.java:688)
    	at java.awt.EventQueue$3.run(EventQueue.java:686)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:697)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at form_port_app.NEBAS.<init>(NEBAS.java:110)
    	at form_port_app.NEBAS$38.run(NEBAS.java:2856)
    	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)
    	at java.awt.EventQueue.access$200(EventQueue.java:103)
    	at java.awt.EventQueue$3.run(EventQueue.java:688)
    	at java.awt.EventQueue$3.run(EventQueue.java:686)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:697)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: Unknown column 'New_Used' in 'field list'

    Debug the SQL by logging the actual SQL statement used.
    Then copy that statement and run it in whatever MySQL front end you use and check that it works.

    That's step 1.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Unknown column 'id' in 'field list'
    By peace76 in forum Java Servlet
    Replies: 6
    Last Post: 12-12-2013, 07:23 PM
  2. Replies: 0
    Last Post: 10-18-2013, 06:03 PM
  3. Unknown type of an interface field
    By vallach in forum New To Java
    Replies: 2
    Last Post: 11-27-2012, 09:49 AM
  4. unknown column 'abc' in where clause in mysql
    By sandeshyadav in forum JDBC
    Replies: 15
    Last Post: 02-13-2012, 09:31 PM
  5. hibernate unknown column
    By arpho in forum New To Java
    Replies: 0
    Last Post: 10-15-2011, 11:27 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •