Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Java JDBC PreparedStatment question

Java JDBC PreparedStatment question

From: Andy Kriger <kokaku_at_earthlink.net>
Date: Sun, 26 Aug 2001 16:35:58 GMT
Message-ID: <Xns91097F86970CAkokakuearthlinknet@207.217.77.25>


i posted this to comp.lang.java.databases without much response so i'm expanding my search...

i am running into a null pointer exception using a PreparedStatement. not sure what is causing it but here is the situation:

using a JSP running on WebLogic6.0sp1 to pull data from an Oracle8i dB. the connection to the dB is through a connection pool setup in the Weblogic config.xml. requests to the dB are made using a PreparedStatement where the arguments are set using setObject. the 1st time i view the JSP, the data appears. after that, when i refresh the page, sometimes i get the exeception that follows this explanation. refreshing more, sometimes the data will appear again, sometimes not. i do not know what is causing the problem in checkBindTypes. Oracle's MetaLink support site has no info. BEA's support site has no info.

here's the method i use to get a ResultSet using a PreparedStatement... public ResultSet getData(String sqlQuery, Object[] args) {

	ResultSet result = null;
	Connection cnx = getConnection();
	PreparedStatement stmt = null;
	try {
		if(cnx != null)
			stmt = cnx.prepareStatement(sqlQuery);
		for(int i = 0; stmt != null && i < args.length; i++)
			stmt.setObject(i+1, args[i]);
		if(stmt != null)
			result = stmt.executeQuery();
	} catch(SQLException sqlEx) {
    	    	// exception handling code deleted
	}
	return result;

}

the JSP calls this passing in a my SQL query string and a String[] as its argument (e.g. new String[] {"IBM"} ). the column being dynamically tested in the where clause of the SQL query is a VARCHAR2 column so the String should be accepted. it is some of the time, but i'm wondering why the request would sometimes fail.

is this a known driver problem? or is there a check that needs to be done to avoid this? has anyone run into this problem? anyone have any ideas on what's going on?

thx Received on Sun Aug 26 2001 - 11:35:58 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US