Results 1 to 11 of 11
  1. #1
    bikkerss is offline Member
    Join Date
    Dec 2009
    Posts
    20
    Rep Power
    0

    Default netbeans database problem

    i'm a novice in programming and i have the following problem
    i'm trying to fill a combobox with strings collected from the resultset from a query.
    with numbers i can get it to work but not white strings can sombody show my an example ?

    i get the error table/view *** not exist

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    bikkerss is offline Member
    Join Date
    Dec 2009
    Posts
    20
    Rep Power
    0

    Default

    here it is

    db class

    Java Code:
     public class DATABANK
    {
    public Connection conn = null;
    public Statement stmt = null;
    public ResultSet rs = null;
    
    public DATABANK(String sql)
    {
    try {
    String dbURL = "jdbc:derby://localhost:1527/INFOREGISTRATIE";
    Class.forName("org.apache.derby.jdbc.ClientDriver" );
    conn =DriverManager.getConnection(dbURL);
    
    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, ResultSet.CONCUR_UPDATABLE);
    rs=stmt.executeQuery(sql);
    
    //rs.close();
    }
    catch (Exception ex)
    {
    JOptionPane.showMessageDialog(null,ex.getMessage() );
    }

    }
    }

    event

    Java Code:
     private void jComboBoxmedewerkerMouseClicked(java.awt.event.Mou seEvent evt) { 
    databankmedewerkers= new DATABANK("select * from MEDEWERKERS where MEDEWERKERNAAM= " + jComboBoxmedewerker.getSelectedItem());
    try {
    databankmedewerkers.rs.first();
    
    medewerker.setText(databankmedewerkers.rs.getString("medewerkernaam"));
    databankmedewerkers.rs.close();
    } catch (SQLException ex) {
    
    }
    }
    Last edited by bikkerss; 12-30-2009 at 01:11 PM.

  4. #4
    bikkerss is offline Member
    Join Date
    Dec 2009
    Posts
    20
    Rep Power
    0

    Default

    Nobody that sees the problem ?

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by bikkerss View Post
    Nobody that sees the problem ?
    You may wish to post the error messages as was requested above, and use code tags (as was requested above).

  6. #6
    bikkerss is offline Member
    Join Date
    Dec 2009
    Posts
    20
    Rep Power
    0

    Default

    Error code:

    Syntax error: Encountered "null" at line 1 column 49

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at eindwerkinfovragen.INGAVEFORM.jComboBoxmedewerkerM ouseClicked(INGAVEFORM.java:795)
    at eindwerkinfovragen.INGAVEFORM.access$100(INGAVEFOR M.java:25)
    at eindwerkinfovragen.INGAVEFORM$2.mouseClicked(INGAV EFORM.java:271)
    at java.awt.AWTEventMulticaster.mouseClicked(AWTEvent Multicaster.java:253)
    at java.awt.Component.processMouseEvent(Component.jav a:6266)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
    at java.awt.Component.processEvent(Component.java:602 8)
    at java.awt.Container.processEvent(Container.java:204 1)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4630)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2099)
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4574)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4247)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2475 )
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)


    it's weird beceause i don't have 49 colums

  7. #7
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    What is line 795 of INGAVEFORM.java?

  8. #8
    bikkerss is offline Member
    Join Date
    Dec 2009
    Posts
    20
    Rep Power
    0

    Default

    databankmedewerkers.rs.first();

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  10. #10
    bikkerss is offline Member
    Join Date
    Dec 2009
    Posts
    20
    Rep Power
    0

    Default

    whitch would indicate the query is empty or do i miss understand ?
    i have filled the database

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

    Default

    A resultset will not come back null* from a query. It will simply be empty (this is not the same as null).

    However this - "Syntax error: Encountered "null" at line 1 column 49" - is a SQL error, implying you have a problem in your SQL statement. Since you then continue on in your code it seems you ignore this problem and assume your query has worked.

    I'm guessing a bit, but I suspect it's down to you concatentiaing your query together rather than using a PreparedStatement.


    * - Except for one db that eludes me at the moment, but it's not likely to be the one you're using.

Similar Threads

  1. Using Derby Database in Netbeans
    By DavidG24 in forum New To Java
    Replies: 1
    Last Post: 09-14-2009, 01:29 PM
  2. database with mysql using the netbeans 6.0
    By kwesiaryee in forum New To Java
    Replies: 2
    Last Post: 05-02-2008, 04:27 AM
  3. Problem with wsimport / Netbeans
    By buk110 in forum Advanced Java
    Replies: 0
    Last Post: 03-17-2008, 07:47 PM
  4. netBeans problem Restated
    By elizabeth in forum NetBeans
    Replies: 1
    Last Post: 08-07-2007, 08:49 PM
  5. Problem with display in Netbeans 5.5
    By Albert in forum NetBeans
    Replies: 1
    Last Post: 07-13-2007, 03:33 PM

Posting Permissions

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