To search data in Salesforce using external application, search () method is used.
Execute a text search in your organization’s data. Use search () to search for records based on a search string. The search () call supports searching custom objects. For an extensive discussion about the syntax and rules used for text searches, see Salesforce Object Search Language (SOSL). Certain objects cannot be searched via the API, such as Attachment objects. To search an object via the search () call, the object must be configured as searchable (isSearchable is true). To determine whether an object can be searched, your client application can invoke the describeSObjects() call on the object and inspect its searchable property.
SearchResult = connection.search(String searchString);
where connection is an object of EnterpriseConnection.
Sample JAVA Program to search data in Salesforce