Posted By:
Eric_Belloma
Posted On:
Thursday, November 1, 2001 07:13 PM
I have an applet that sends a text request to a servlet that (via a JNDI lookup) makes a database connection and retrieves a large ammount of information. After a succession of queries, a custom object (implementing the serialized interface) is populated (mostly made up of Strings and Vectors) and this data is sent up to the applet for user to manipulate before a request is made to save. I am receiving an EOFException / NullPointerException inside the applet randomly. Have done this process before and never run into this problem, but I have never moved this much data at once serialized (~300-500k). Error retrieving CSTS_queryRunner data: java.io.EOFException: Expecting code Error retrieving blank CSTS_projectHeader data: java.la
More>>
I have an applet that sends a text request to a servlet that (via a JNDI lookup) makes a database connection and retrieves a large ammount of information. After a succession of queries, a custom object (implementing the serialized interface) is populated (mostly made up of Strings and Vectors)
and this data is sent up to the applet for user to manipulate before a request is made to save. I am receiving an EOFException / NullPointerException inside the applet randomly. Have done this process before and never run into this problem, but I have never moved this much data at once serialized (~300-500k).
Error retrieving CSTS_queryRunner data: java.io.EOFException: Expecting code
Error retrieving blank CSTS_projectHeader data: java.lang.NullPointerException
Code attached below, any comments would be appreciated:
APPLET:
Object o = new Object();
try {
String arg_string = "QUERY_STRING=" + URLEncoder.encode(query_string) + "&EXPECTED_SIZE=" +
expected_size;
URL destination = new URL( servlet_location );
URLConnection con = destination.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
DataOutputStream out = new DataOutputStream( con.getOutputStream() );
out.writeBytes( arg_string );
out.flush();
out.close();
ObjectInputStream in = new ObjectInputStream( con.getInputStream() );
o = in.readObject();
try {
query_output = (Vector)o;
} catch( ClassCastException cast_e ) {
if( o instanceof java.lang.String ) {
System.out.println( (String)o );
} else {
throw cast_e;
}
} finally {
in.close();
}
} catch( Exception e ) {
System.out.println("Error retrieving CSTS_queryRunner data: " + e.toString());
}
SERVLET:
out = new ObjectOutputStream( res.getOutputStream() );
out.reset();
//Lookup the JDBC connection object from session
try {
context = new InitialContext();
source = (DataSource)context.lookup("java:comp/env/jdbc/CSTS_CON");
connection = source.getConnection( (String)session.getValue("CSTS_USERNAME"), (String)session.getValue("CSTS_PASSWORD") );
} catch( Exception e ) {
throw new Exception( "Error while retrieving DB Connection from session: " + e.toString() );
}
// ########################################################################
query_string = req.getParameter("QUERY_STRING");
String tmp_expected_size = req.getParameter("EXPECTED_SIZE");
int expected_size = 10;
try {
expected_size = (new Integer(tmp_expected_size)).intValue();
} catch(
NumberFormatException num_e ) { }
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery( query_string );
Vector v = new Vector( expected_size );
int col_count = (rs.getMetaData()).getColumnCount();
while( rs.next() ) {
String data[] = new String[ col_count ];
for( int i=1; i
<=col_count; i++ ) {
try {
data[i-1] = new String( rs.getString(i) );
} catch( Exception junk_e ) {
data[i-1] = new String("");
}
}
v.addElement( data );
}
out.writeObject( v );
out.flush();
rs.close();
stmt.close();
} catch( Exception e ) {
out.writeObject( new String("CSTS_queryRunner: " + e.toString()) );
System.err.println( "*****CSTS Application Error: " + (new java.util.Date()) + " *****" );
System.err.println( ">>>>>Running query: " + query_string );
e.printStackTrace();
System.err.println( "***************************************************" );
} finally {
out.close();
try {
connection.close();
} catch( Exception e ) {
System.err.println( "*****CSTS Application Error: " + (new java.util.Date()) + " *****" );
e.printStackTrace();
System.err.println( "***************************************************" );
}
} //end global try
<<Less