boolean isUpdateable ( ) throws SQLException { checkClosed ( ) ; if ( resultsetconcurrency == ResultSet . CONCUR_READ_ONLY ) { throw new PSQLException ( GT . tr ( "ResultSets with concurrency CONCUR_READ_ONLY cannot be updated." ) , PSQLState . INVALID_CURSOR_STATE ) ; } if ( updateable ) { return true ; } connection . getLogger ( ) . log ( Level . FINE , "checking if rs is updateable" ) ; parseQuery ( ) ; if ( ! singleTable ) { connection . getLogger ( ) . log ( Level . FINE , "not a single table" ) ; return false ; } connection . getLogger ( ) . log ( Level . FINE , "getting primary keys" ) ; // // Contains the primary key? // primaryKeys = new ArrayList < PrimaryKey > ( ) ; // this is not strictly jdbc spec, but it will make things much faster if used // the user has to select oid, * from table and then we will just use oid usingOID = false ; int oidIndex = findColumnIndex ( "oid" ) ; // 0 if not present int i = 0 ; int numPKcolumns = 0 ; // if we find the oid then just use it // oidIndex will be >0 if the oid was in the select list if ( oidIndex > 0 ) { i ++ ; numPKcolumns ++ ; primaryKeys . add ( new PrimaryKey ( oidIndex , "oid" ) ) ; usingOID = true ; } else { // otherwise go and get the primary keys and create a list of keys String [ ] s = quotelessTableName ( tableName ) ; String quotelessTableName = s [ 0 ] ; String quotelessSchemaName = s [ 1 ] ; java . sql . ResultSet rs = connection . getMetaData ( ) . getPrimaryKeys ( "" , quotelessSchemaName , quotelessTableName ) ; while ( rs . next ( ) ) { numPKcolumns ++ ; String columnName = rs . getString ( 4 ) ; // get the columnName int index = findColumnIndex ( columnName ) ; if ( index > 0 ) { i ++ ; primaryKeys . add ( new PrimaryKey ( index , columnName ) ) ; // get the primary key information } } rs . close ( ) ; } connection . getLogger ( ) . log ( Level . FINE , "no of keys={0}" , i ) ; if ( i < 1 ) { throw new PSQLException ( GT . tr ( "No primary key found for table {0}." , tableName ) , PSQLState . DATA_ERROR ) ; } updateable = ( i == numPKcolumns ) ; connection . getLogger ( ) . log ( Level . FINE , "checking primary key {0}" , updateable ) ; return updateable ; }
Is this ResultSet updateable?