Results 1 to 2 of 2

Thread: Sql

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

    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'";
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at Dier.jMenuItem1ActionPerformed(
    at Dier.access$000(
    at Dier$1.actionPerformed(
    at javax.swing.AbstractButton.fireActionPerformed(Abs
    at javax.swing.AbstractButton$Handler.actionPerformed (
    at javax.swing.DefaultButtonModel.fireActionPerformed (
    at javax.swing.DefaultButtonModel.setPressed(DefaultB
    at javax.swing.AbstractButton.doClick(AbstractButton. java:302)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Bas
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mou seReleased(
    at java.awt.Component.processMouseEvent(Component.jav a:5517)
    at javax.swing.JComponent.processMouseEvent(JComponen
    at java.awt.Component.processEvent( 2)
    at java.awt.Container.processEvent( 6)
    at java.awt.Component.dispatchEventImpl(Component.jav a:3984)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2024)
    at java.awt.Component.dispatchEvent( 19)
    at java.awt.LightweightDispatcher.retargetMouseEvent(
    at java.awt.LightweightDispatcher.processMouseEvent(C
    at java.awt.LightweightDispatcher.dispatchEvent(Conta
    at java.awt.Container.dispatchEventImpl(Container.jav a:2010)
    at java.awt.Window.dispatchEventImpl( )
    at java.awt.Component.dispatchEvent( 19)
    at java.awt.EventQueue.dispatchEvent( 463)
    at java.awt.EventDispatchThread.pumpOneEventForHierar chy(
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(
    at java.awt.EventDispatchThread.pumpEvents(EventDispa
    at java.awt.EventDispatchThread.pumpEvents(EventDispa

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    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(
    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.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Posting Permissions

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