No you are not thinking in the right direction. See the code you have written
public int getNumberOfThreadBeans_forReceiver( String memberName ) throws AssertionException, DatabaseException { Connection conn = null; PreparedStatement stmt = null; String query = "SELECT count(*) FROM message_thread WHERE message_receiver = '" + memberName + "'"; ResultSet rs = null; try { conn = DBConnection.getDBConnection(); stmt = conn.prepareStatement( query ); stmt.setString( 1, memberName ); rs = stmt.executeQuery();
as you can see you have written
String query = "SELECT count(*) FROM message_thread WHERE message_receiver = '" + memberName + "'"; and you are using PreparedStatement. You are setting the message_receiver here in this query and then you are trying to use
stmt.setString(1,memberName).There is no ? in the query.
So Strange. Isn't it?
Use
String query = "SELECT count(*) FROM message_thread WHERE message_receiver = ?"; instead. It will solve the problem.
[ May 20, 2004: Message edited by: Ali Gohar ]