Results 1 to 4 of 4
  1. #1
    Amit20 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Post Next Button Error

    Hi Friends!
    I have encountered error with my code.
    I have a "next" button in my application. But when i try to run a code on its
    click, for first time it runs perfectly fine but for next attempt it throws a NullPointerException and also the button remains pressed. Please Help. The button click code is as follows:

    if(s.equals("Next"))
    {
    try
    {
    connn=DriverManager.getConnection("jdbc:odbc:Atten dance");
    st=connn.createStatement(ResultSet.TYPE_SCROLL_INS ENSITIVE,ResultSet.CONCUR_UPDATABLE);
    rs=st.executeQuery("Select * from Student");

    rs.next();




    int a=rs.getInt(1);
    String b=rs.getString(2);
    String c=rs.getString(3);
    String ak=new Integer(a).toString();

    text2.setText(ak);
    text3.setText(b);
    text4.setText(c);





    }
    catch(SQLException z)
    {
    System.out.println("Exception z" +z);
    }
    }

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    6

    Default

    First, using the code tags makes your code much more readable. Next, you don't post the trace of the exception so we have no clue what line it is being thrown on. Last, you should close the database connection when you are done with it.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    Is this code in a worker thread?
    If not that would probably explain the button staying pressed after a crash.

  4. #4
    Amit20 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Smile Thanks!!!

    Thanks!
    I'll try to inculcate the mentioned things.

Similar Threads

  1. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 09:31 AM
  2. Replies: 1
    Last Post: 03-10-2010, 01:53 PM
  3. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  4. Replies: 1
    Last Post: 10-26-2009, 04:38 PM
  5. Replies: 3
    Last Post: 01-23-2009, 08:53 AM

Posting Permissions

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