question: private boolean checkForKey ( ) throws Exception { String query = m_query ; query = query . replaceAll ( " +" , " " ) ; if ( ! query . startsWith ( "SELECT *" ) ) { return false ; } m_orderBy . clear ( ) ; if ( ! m_DataBaseConnection . isConnected ( ) ) { m_DataBaseConnection . connectToDatabase ( ) ; } DatabaseMetaData dmd = m_DataBaseConnection . getMetaData ( ) ; String table = endOfQuery ( true ) ; ResultSet rs = dmd . getPrimaryKeys ( null , null , table ) ; while ( rs . next ( ) ) { m_orderBy . add ( rs . getString ( 4 ) ) ; } rs . close ( ) ; if ( m_orderBy . size ( ) != 0 ) { return true ; } rs = dmd . getBestRowIdentifier ( null , null , table , DatabaseMetaData . bestRowSession , false ) ; ResultSetMetaData rmd = rs . getMetaData ( ) ; int help = 0 ; while ( rs . next ( ) ) { m_orderBy . add ( rs . getString ( 2 ) ) ; help ++ ; } rs . close ( ) ; if ( help == rmd . getColumnCount ( ) ) { m_orderBy . clear ( ) ; } if ( m_orderBy . size ( ) != 0 ) { return true ; } return false ; }
target:  Checks for a unique key using the JDBC driver's method: getPrimaryKey(), getBestRowIdentifier(). Depending on their implementation a key can be detected. The key is needed to order the instances uniquely for an inremental loading. If an existing key cannot be detected, use -P option.