Results 1 to 2 of 2

Thread: Sql

  1. #1
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Smile Sql

    I can't seem to figure out whats wrong with my SQL statement. This one I copied from a query i made in my database and it still doesn't work.

    Java Code:
    String sql = "SELECT Diere.ID, Diere.[Scientific Name], Diere.Naam FROM Diere WHERE Diere.Beskrywing = 'Bird'";
    Errors:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at Dier.jMenuItem1ActionPerformed(Dier.java:255)
    at Dier.access$000(Dier.java:21)
    at Dier$1.actionPerformed(Dier.java:137)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1849)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2169)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:420)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:258)
    at javax.swing.AbstractButton.doClick(AbstractButton. java:302)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Bas icMenuItemUI.java:1051)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mou seReleased(BasicMenuItemUI.java:1092)
    at java.awt.Component.processMouseEvent(Component.jav a:5517)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3135)
    at java.awt.Component.processEvent(Component.java:528 2)
    at java.awt.Container.processEvent(Container.java:196 6)
    at java.awt.Component.dispatchEventImpl(Component.jav a:3984)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2024)
    at java.awt.Component.dispatchEvent(Component.java:38 19)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4212)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3892)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3822)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2010)
    at java.awt.Window.dispatchEventImpl(Window.java:1791 )
    at java.awt.Component.dispatchEvent(Component.java:38 19)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 463)
    at java.awt.EventDispatchThread.pumpOneEventForHierar chy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:110)

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Moderator
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    9,928
    Rep Power
    16

    Default Re: Sql

    First and foremost, you shouldn't be running JDBC code on the EDT. Go though this Tutorial Lesson: Concurrency in Swing (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    A NullPointerException isn't at all likely to arise from a defective SQL statement. At least, not unless you're swallowing some other Exception somewhere, and even then the chances are remote.
    Java Code:
    at Dier.jMenuItem1ActionPerformed(Dier.java:255)
    What's on that line? And stay away from advanced tools like visual designers until you have a firm grasp of the basics, and have learned how to refactor the autogenerated code to use meaningful variable names.

    db
    Why do they call it rush hour when nothing moves? - Robin Williams

Posting Permissions

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