private int getColIndex ( String colName , String tabName ) { int ordPos = 0 ; try { if ( cConn == null ) { return - 1 ; } if ( dbmeta == null ) { dbmeta = cConn . getMetaData ( ) ; } ResultSet colList = dbmeta . getColumns ( null , null , tabName , colName ) ; colList . next ( ) ; ordPos = colList . getInt ( "ORDINAL_POSITION" ) ; colList . close ( ) ; } catch ( SQLException e ) { System . out . println ( "SQL Exception: " + e . getMessage ( ) ) ; } return ordPos - 1 ; }
answer the index of the column named colName in the table tabName