Results 1 to 7 of 7
  1. #1
    mooey1232003 is offline Member
    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0

    Default Help implementing JDBC

    Hi i need help implementing JDBC in my program. The program stores info in a data file but i want it to save to a MS Access and also be able to read in the access file from the program.
    Thanks.
    Attached Files Attached Files

  2. #2
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    Using JDBC is simple.

    1. Convert your data file into database tables and store it seprately.
    2. Access data on database using JDBC.

    Here is a good tutorial for JDBC.

  3. #3
    mooey1232003 is offline Member
    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0

    Default

    Thanks I will try that

  4. #4
    mooey1232003 is offline Member
    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0

    Default

    I tried to get the add button to connect to the DB but when i click the button i get errors.


    "
    java.lang.NullPointerException
    at OperationHandler.ToDataBase(InfoBook.java:1027)
    at InfoBook.actionPerformed(InfoBook.java:166)
    at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.act ionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    "

    When i click the add new button it points to "public void toDatbase"
    (line 1023)
    The error is around there but i cant find it.
    Source code.
    Can anyone please help

  5. #5
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    Please write content of InfoBook.java here. (Place the code inside [code] tags.)

  6. #6
    mooey1232003 is offline Member
    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0

    Default

    I tried to put it inside tags but it said that i had to shorten it.I hope im not being to much trouble.

    http://mooey.50webs.com/InfoBook.java

    It is on the link that a provided

    Thanks

  7. #7
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    As far as i see, line 1027 is the line below:

    Java Code:
    String lblFirstName = txtFirstName.getText ();
    The lines below are similar. I think your txtFirstName object is null there. You can check if it is null or not as follows:

    Java Code:
    if (txtFirstName == null) System.out.println("txtFirstName is null");
    There should be some null objects there since NullPointerException occurs when you try to access properties or methods of a null object.

Similar Threads

  1. Implementing Iterator
    By Harb in forum New To Java
    Replies: 13
    Last Post: 11-21-2009, 08:25 PM
  2. Replies: 0
    Last Post: 04-01-2008, 11:17 AM
  3. implementing a button instead.
    By birdofprey in forum AWT / Swing
    Replies: 3
    Last Post: 02-18-2008, 04:21 AM
  4. Implementing an interface
    By bugger in forum Advanced Java
    Replies: 1
    Last Post: 01-09-2008, 02:35 PM
  5. Replies: 0
    Last Post: 09-28-2007, 01:56 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
  •