if (index.isUnique() && (index.getName() != null)) { int underscorePos = index.getName().lastIndexOf('_');  if (underscorePos > 0) { String tableName = index.getName().substring(0, underscorePos); String id        = index.getName().substring(underscorePos + 1);  if (table.getName().startsWith(tableName)) { try { Long.parseLong(id); return true; } catch (NumberFormatException ex) {  } } } } return false;
StringBuffer query = new StringBuffer();  query.append("SELECT name = sysindexes.name FROM sysindexes, sysobjects WHERE sysobjects.name = '"); query.append(table.getName()); query.append("' AND sysindexes.name = '"); query.append(index.getName()); query.append("' AND sysobjects.id = sysindexes.id AND (sysindexes.status & 2048) > 0");  Statement stmt = getConnection().createStatement();  try { ResultSet rs     = stmt.executeQuery(query.toString()); boolean   result = rs.next();  rs.close(); return result; } finally { stmt.close(); }
    protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table, Index index)    {        // Sybase defines a unique index "<table name>_<integer numer>" for primary keys    	if (index.isUnique() && (index.getName() != null))    	{	    	int underscorePos = index.getName().lastIndexOf('_');		    	if (underscorePos > 0)	    	{	    		String tableName = index.getName().substring(0, underscorePos);	    		String id        = index.getName().substring(underscorePos + 1);		    		if (table.getName().startsWith(tableName))	    		{		    		try		    		{		    			Long.parseLong(id);		    			return true;		    		}		    		catch (NumberFormatException ex)		    		{		    			// we ignore it		    		}	    		}	    	}    	}    	return false;    }