Bongani Hlope on Thu, 20 Feb 2003 16:38:04 +0200 (SAST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Linux dev] Re: Java NullPointerException


Jarrod Hermer wrote:
<snip>


ResultSet rs = null;

try
{
	CallableStatement cs = conn.prepareCall("{call
GetUserByName(?)}");
	cs.setString(1, name);
	rs = cs.executeQuery();
}
catch(SQLException ex)
{
	System.out.println("ERROR getting user");
	System.out.println(ex.getMessage());
}

while(rs.next())
{
	// Do Stuff
}
rs.close();

------------------------------------------------------------------------
----

On my development machine it functions without any problems. However on
my production machine which I am convinced is identical the program
crashes with a Java.NullPointerException error.

<snip>

Ussually java tells you the line number where the exception was thrown, the only place I see that the error occured is the while(rs.next()) statement.

So you must see a "ERROR getting user" before the NullPointerException, which could be caused by either
1. The stored proc does not exist on you live database
2. Or something else went wrong here


CallableStatement cs = conn.prepareCall("{call GetUserByName(?)}");
 	cs.setString(1, name)
--
"Only two things are infinite, the universe and human stupidity,
	and I'm not sure about the former."
		-Albert Einstein