Buggy code:
query ( ) ; byte_image = bs64 . decode ( itr_req . getIdeal_type ( ) ) ; ideal_image = ( Integer . toString ( user_id ) ) + "_ideal_type.jpg" ; ImageCodec . saveImage ( byte_image , "ideal_type" , ideal_image ) ; } catch ( SQLException e ) { db . printError ( e , query ) ; } IdealTypeRegisterAck itr_ack = new IdealTypeRegisterAck ( Packet . SUCCESS ) ; output = PacketCodec . encode_IdealTypeRegisterAck ( itr_ack ) ; try { out . println ( output ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } break ; case Packet . PK_IDEAL_SCH_REQ : IdealTypeSearchReq its_req = PacketCodec . decode_IdealTypeSearchReq ( src . getData ( ) ) ; int begin = 0 ; int end = 0 ; ArrayList < ImageNameSet > ideal_arr = new ArrayList < ImageNameSet > ( ) ; ArrayList < ImageSimilarity > image_arr = null ; query = ( "select<seq2seq4repair_space>user_id<seq2seq4repair_space>from<seq2seq4repair_space>login_data<seq2seq4repair_space>where<seq2seq4repair_space>screen_name<seq2seq4repair_space>=<seq2seq4repair_space>'" + ( its_req . getScreen_name ( ) ) ) + "'" ; try { rs = db . getStatement ( ) . executeQuery ( query ) ; rs . next ( ) ; user_id = rs . getInt ( "user_id" ) ; rs . close ( ) ; } catch ( SQLException e ) { db . printError ( e , query ) ; } image_arr = ComparisonSimilarity . getSimilarImage ( ( ( Integer . toString ( user_id ) ) + "_ideal_type.jpg" ) ) ; QuickSort . quickSort ( image_arr , 0 , ( ( image_arr . size ( ) ) - 1 ) ) ; for ( int i = 0 ; ( i < 5 ) && ( i < ( image_arr . size ( ) ) ) ; ++ i ) { end = ( image_arr . get ( i ) . getName ( ) . indexOf ( '_' ) ) - 1 ; user_id = Integer . parseInt ( image_arr . get ( i ) . getName ( ) . substring ( begin , end ) ) ; query = ( ( "select<seq2seq4repair_space>screen_name<seq2seq4repair_space>from<seq2seq4repair_space>login_data<seq2seq4repair_space>" + "where<seq2seq4repair_space>user_id<seq2seq4repair_space>=<seq2seq4repair_space>'" ) + ( Integer . toString ( user_id ) ) ) + "';" ; try { rs = db . getStatement ( ) . executeQuery ( query ) ; rs . next ( ) ; screen_name = rs . getString ( "screen_name" ) ; rs . close ( ) ; } catch ( SQLException e ) { db . printError ( e , query ) ; } byte_image = ImageCodec . loadImageToByteArray ( "profile" , image_arr . get ( i ) . getName ( ) ) ; thumbnail_image = bs64 . encode ( byte_image ) ; ideal_arr . add ( new ImageNameSet ( screen_name , thumbnail_image ) ) ; } IdealTypeSearchAck its_ack = new IdealTypeSearchAck ( ) ; its_ack . setIdeal_types ( ideal_arr ) ; output = PacketCodec . encode_IdealTypeSearchAck ( its_ack ) ; try { out . println ( output ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } break ; case Packet . PK_CONTACT_REQ : ContactReq c_req = PacketCodec . decode_ContactReq ( src . getData ( ) ) ; send_id = 0 ; rec_id = 0 ; query = ( "select<seq2seq4repair_space>user_id<seq2seq4repair_space>from<seq2seq4repair_space>login_data<seq2seq4repair_space>where<seq2seq4repair_space>screen_name<seq2seq4repair_space>=<seq2seq4repair_space>'" + ( c_req . getSend_user ( ) ) ) + "'" ; try { rs = db . getStatement ( ) . executeQuery ( query ) ; rs . next ( ) ; send_id = rs . getInt ( "user_id" ) ; rs . close ( ) ; } catch ( SQLException e ) { db . printError ( e , query ) ; } query = ( "select<seq2seq4repair_space>user_id<seq2seq4repair_space>from<seq2seq4repair_space>login_data<seq2seq4repair_space>where<seq2seq4repair_space>screen_name<seq2seq4repair_space>=<seq2seq4repair_space>'" + ( c_req . getRec_user ( ) ) ) + "'" ; try { rs = db . getStatement ( ) . executeQuery ( query ) ; rs . next ( ) ; rec_id = rs . getInt ( "user_id" ) ; rs . close ( ) ; } catch ( SQLException e ) { db . printError ( e , query ) ; } try { query = ( ( ( ( ( ( "insert<seq2seq4repair_space>into<seq2seq4repair_space>contact(send_id,<seq2seq4repair_space>receive_id,<seq2seq4repair_space>isAccept)<seq2seq4repair_space>" + "values(" ) + ( Integer . toString ( send_id ) ) ) + "," ) + ( Integer . toString ( rec_id ) ) ) + "," ) + ( Integer . toString ( STANDBY ) ) ) + ")" ; db . getStatement ( ) . executeUpdate ( query ) ; } catch ( SQLException e ) { db . printError ( e , query ) ; } ContactAck c_ack = new ContactAck ( Packet . SUCCESS ) ; output = PacketCodec . encode_ContactAck ( c_ack ) ; try { out . println ( output ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } break ; case Packet . PK_REPLY_CON_REQ : ReplyContactReq rc_req = PacketCodec . decode_ReplyContactReq ( src . getData ( ) ) ; send_id = 0 ; rec_id = 0 ; query = ( "select<seq2seq4repair_space>user_id<seq2seq4repair_space>from<seq2seq4repair_space>login_data<seq2seq4repair_space>where<seq2seq4repair_space>screen_name<seq2seq4repair_space>=<seq2seq4repair_space>'" + ( rc_req . getSend_user ( ) ) ) + "'" ; try { rs = db . getStatement ( ) . executeQuery ( query ) ; rs . next ( ) ; send_id = rs . getInt ( "user_id" ) ; rs . close ( ) ; } catch ( SQLException e ) { db . printError ( e , query ) ; } query = ( "select<seq2seq4repair_space>user_id<seq2seq4repair_space>from<seq2seq4repair_space>login_data<seq2seq4repair_space>where<seq2seq4repair_space>screen_name<seq2seq4repair_space>=<seq2seq4repair_space>'" + ( rc_req . getRec_user ( ) ) ) + "'" ; try { rs = db . getStatement ( ) . executeQuery ( query ) ; rs . next ( ) ; rec_id = rs . getInt ( "user_id" ) ; rs . close ( ) ; } catch ( SQLException e ) { db . printError ( e , query ) ; } if ( ( rc_req . getReply ( ) ) == ( ContactInfo . REJECT ) ) { query = ( ( "delete<seq2seq4repair_space>from<seq2seq4repair_space>contact<seq2seq4repair_space>where<seq2seq4repair_space>send_id<seq2seq4repair_space>=<seq2seq4repair_space>" + ( Integer . toString ( send_id ) ) ) + "<seq2seq4repair_space>and<seq2seq4repair_space>receive_id<seq2seq4repair_space>=<seq2seq4repair_space>" ) + ( Integer . toString ( rec_id ) ) ; try { db . getStatement ( ) . executeUpdate ( query ) ; } catch ( SQLException e ) { db . printError ( e , query ) ; } } else if ( ( rc_req . getReply ( ) ) == ( ContactInfo . ACCEPT ) ) { query = ( ( ( ( "update<seq2seq4repair_space>contact<seq2seq4repair_space>set<seq2seq4repair_space>isAccept<seq2seq4repair_space>=<seq2seq4repair_space>" + ( Integer . toString ( rc_req . getReply ( ) ) ) ) + "<seq2seq4repair_space>where<seq2seq4repair_space>send_id<seq2seq4repair_space>=<seq2seq4repair_space>" ) + ( Integer . toString ( send_id ) ) ) + "<seq2seq4repair_space>and<seq2seq4repair_space>receive_id<seq2seq4repair_space>=<seq2seq4repair_space>" ) + ( Integer . toString ( rec_id ) ) ; try { db . getStatement ( ) . executeUpdate ( query ) ; } catch ( SQLException e ) { db . printError ( e , query ) ; } } ReplyContactAck rc_ack = new ReplyContactAck ( Packet . SUCCESS ) ; output = PacketCodec . encode_ReplyContactAck ( rc_ack ) ; try { out . println ( output ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } break ; case Packet . PK_GET_CON_REQ : GetContactReq gc_req = PacketCodec . decode_GetContactReq ( src . getData ( ) ) ; query = ( "select<seq2seq4repair_space>user_id<seq2seq4repair_space>from<seq2seq4repair_space>login_data<seq2seq4repair_space>where<seq2seq4repair_space>screen_name<seq2seq4repair_space>=<seq2seq4repair_space>'" + ( gc_req . getScreen_name ( ) ) ) + "'" ; try { rs = db . getStatement ( ) . executeQuery ( query ) ; rs . next ( ) ; user_id = rs . getInt ( "user_id" ) ; rs . close ( ) ; } catch ( SQLException e ) { db . printError ( e , query ) ; } GetContactAck gc_ack = new GetContactAck ( ) ; ArrayList < int [ ] > con_arr = new ArrayList < int [ ] > ( ) ; int [ ] temp = null ; <START_BUG> query = "select<seq2seq4repair_space>send_id,<seq2seq4repair_space>isAccept<seq2seq4repair_space>from<seq2seq4repair_space>contact<seq2seq4repair_space>where<seq2seq4repair_space>user_id<seq2seq4repair_space>=<seq2seq4repair_space>" + ( Integer . toString ( user_id ) ) ; <END_BUG>

Fix:
query = "select<seq2seq4repair_space>send_id,<seq2seq4repair_space>isAccept<seq2seq4repair_space>from<seq2seq4repair_space>contact<seq2seq4repair_space>where<seq2seq4repair_space>receive_id<seq2seq4repair_space>=<seq2seq4repair_space>" + ( Integer . toString ( user_id ) ) ;