The Artima Developer Community
Sponsored Link

Java Answers Forum
null pointer exception in JBuilder

2 replies on 1 page. Most recent reply: Apr 9, 2003 6:32 AM by Adam Duffy

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Bill Arse

Posts: 1
Nickname: syphon1982
Registered: Apr, 2003

null pointer exception in JBuilder Posted: Apr 9, 2003 5:06 AM
Reply to this message Reply
Advertisement
I keep getting a null pointer exception when trying to use the following code.

Any ideas?

void SubmitToTesterButton_actionPerformed(ActionEvent e)
{
String query4;
String query8;
String query9;
boolean more;
boolean dbErrors = false;





// i want the boolean solved to be turned to yes and
// then to send the problem to the tester panel' list table



//query4 = "INSERT INTO Problem(Solved) "+
// " VALUES ('Yes') ";

//connection.executeUpdate(query4);

query8 = "INSERT INTO ProblemHistory(ProblemNo,RecieveDate, DeployDate)"+
" VALUES ( "+ProbNum+",'"+dateRecText.getText()+"','"+TextFixed.getText()+"')";



connection.executeUpdate(query8);


query9 = "SELECT MAX(TaskNo)"+
" FROM ProblemHistory";
try {
ResultSet rs;

//dbConnection connection = new dbConnection();
int num;
String name;

rs = connection.executeQuery(query9);
more = rs.next();
num = rs.getInt("Expr1000");
System.out.println(num);

if (!more)
{
JOptionPane.showMessageDialog(this,"This requested data does not exist"
,"Access Denied"
,JOptionPane.ERROR_MESSAGE);


return;
}
more = rs.next();
//connection.closeConnection();


}
catch (SQLException error)
{
JOptionPane.showMessageDialog(null,"Error creating connection: "
+error.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
//An error occurred, so set the error flag
dbErrors = true;
}


query4 = "INSERT INTO Programmer(TaskNo, SolutionDetails)"+
" VALUES ("+num+",'"+solutionText.getText()+"' )";

connection.executeUpdate(query4) ;



}


Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: null pointer exception in JBuilder Posted: Apr 9, 2003 6:29 AM
Reply to this message Reply
I think it would be better if you can have break points and debug the code and find out where exactly the NullPointerException is being thrown. Then its easier to help

Adam Duffy

Posts: 168
Nickname: adamduffy
Registered: Feb, 2003

Re: null pointer exception in JBuilder Posted: Apr 9, 2003 6:32 AM
Reply to this message Reply
> I keep getting a null pointer exception when trying to use
> the following code.
>
> Any ideas?
>
> //dbConnection connection = new dbConnection();

Are you opening the database connection somewhere else? Make sure this has been initialised.

If you keep getting a null pointer exception, can you determine which line of the code is throwing the null pointer exception?

Adam

Flat View: This topic has 2 replies on 1 page
Topic: ArrayList Performance Previous Topic   Next Topic Topic: Inner class

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use