Buggy code:
public class PostgresqlAdapter { private static final Logger LOGGER = Logger . getLogger ( PostgresqlAdapter . class ) ; private static PostgresqlAdapter instance = null ; private ComboPooledDataSource cpds = null ; private Properties props = null ; protected PostgresqlAdapter ( ) { } public static PostgresqlAdapter sharedInstance ( ) { } private boolean saveTag ( List < Pair < String , String > > tag , Connection conn , String tagType , long id ) { } public boolean saveNode ( OSMNode node ) { } public boolean saveWay ( OSMWay way ) { Connection conn = null ; PreparedStatement statement = null ; try { conn = cpds . getConnection ( ) ; conn . setAutoCommit ( false ) ; statement = conn . prepareStatement ( ( "INSERT<seq2seq4repair_space>INTO<seq2seq4repair_space>way(id,<seq2seq4repair_space>visible,<seq2seq4repair_space>version,<seq2seq4repair_space>changeset,<seq2seq4repair_space>\"timestamp\",<seq2seq4repair_space>\"user\",<seq2seq4repair_space>uid)<seq2seq4repair_space>" + ( "<seq2seq4repair_space>VALUES<seq2seq4repair_space>" + "(?,<seq2seq4repair_space>?,<seq2seq4repair_space>?,<seq2seq4repair_space>?,<seq2seq4repair_space>to_timestamp(?,<seq2seq4repair_space>'YYYY-MM-DD<seq2seq4repair_space>HH24:MI:SS<seq2seq4repair_space>'),<seq2seq4repair_space>?,<seq2seq4repair_space>?)" ) ) ) ; long id = ( way . attr . containsKey ( "id" ) ) ? Long . parseLong ( way . attr . get ( "id" ) ) : 0L ; boolean visible = ( way . attr . containsKey ( "visible" ) ) ? Boolean . parseBoolean ( way . attr . get ( "visible" ) ) : true ; long version = ( way . attr . containsKey ( "version" ) ) ? Long . parseLong ( way . attr . get ( "version" ) ) : 0L ; long changeset = ( way . attr . containsKey ( "changeset" ) ) ? Long . parseLong ( way . attr . get ( "changeset" ) ) : 0L ; String timestamp = ( way . attr . containsKey ( "timestamp" ) ) ? way . attr . get ( "timestamp" ) : "" ; timestamp = timestamp . replace ( 'T' , '<seq2seq4repair_space>' ) . replace ( 'Z' , '<seq2seq4repair_space>' ) ; String user = ( way . attr . containsKey ( "user" ) ) ? way . attr . get ( "user" ) : "" ; long uid = ( way . attr . containsKey ( "uid" ) ) ? Long . parseLong ( way . attr . get ( "uid" ) ) : 0L ; statement . setLong ( 1 , id ) ; statement . setBoolean ( 2 , visible ) ; statement . setLong ( 3 , version ) ; statement . setLong ( 4 , changeset ) ; statement . setString ( 5 , timestamp ) ; statement . setString ( 6 , user ) ; statement . setLong ( 7 , uid ) ; int rowsAffacted = statement . executeUpdate ( ) ; if ( rowsAffacted == 0 ) { statement . close ( ) ; conn . close ( ) ; return false ; } statement . close ( ) ; if ( ( saveTag ( way . tag , conn , "way" , id ) ) == false ) { statement . close ( ) ; conn . close ( ) ; return false ; } statement . close ( ) ; if ( ( way . nd . size ( ) ) > 0 ) { <START_BUG> statement = conn . prepareStatement ( "INSERT<seq2seq4repair_space>INTO<seq2seq4repair_space>way_nd(way_ref,<seq2seq4repair_space>nd_ref,<seq2seq4repair_space>order)<seq2seq4repair_space>VALUES<seq2seq4repair_space>(?,<seq2seq4repair_space>?,<seq2seq4repair_space>?)" ) ; <END_BUG> for ( int i = 0 ; i < ( way . nd . size ( ) ) ; i ++ ) { long nd_ref = Long . parseLong ( way . nd . get ( i ) ) ; statement . setLong ( 1 , id ) ; statement . setLong ( 2 , nd_ref ) ; statement . setLong ( 3 , i ) ; rowsAffacted = statement . executeUpdate ( ) ; if ( rowsAffacted == 0 ) { statement . close ( ) ; conn . close ( ) ; return false ; } } } conn . commit ( ) ; conn . setAutoCommit ( true ) ; statement . close ( ) ; conn . close ( ) ; } catch ( SQLException e ) { e . printStackTrace ( ) ; try { conn . close ( ) ; statement . close ( ) ; return false ; } catch ( SQLException e1 ) { e1 . printStackTrace ( ) ; return false ; } } return true ; } public boolean saveRelation ( OSMRelation relation ) { } public List < GeomPoint > getPointsOfRelation ( long relation_ref ) { } public List < Long > getRelations ( ) { } public boolean saveRelationBoundingBox ( long relation_ref , GeomBox boundingBox ) { } public List < Long > getWays ( ) { } public List < Long > getHighways ( ) { } public List < GeomPoint > getPointsOfWay ( long way_ref ) { } public boolean saveWayBoundingBox ( long way_ref , GeomBox boundingBox ) { } public boolean saveConnectivity ( GeomPoint p1 , GeomPoint p2 , long way_ref ) { } public List < Pair < String , String > > getTags ( String tagType , long id ) { } }

Fix:
statement = conn . prepareStatement ( "INSERT<seq2seq4repair_space>INTO<seq2seq4repair_space>way_nd(way_ref,<seq2seq4repair_space>nd_ref,<seq2seq4repair_space>\"order\")<seq2seq4repair_space>VALUES<seq2seq4repair_space>(?,<seq2seq4repair_space>?,<seq2seq4repair_space>?)" ) ;