I have a java program, I want to insert data into oracle db and solr at the same time. How can I make sure that data in the db and solr are consistent?
Knowing nothing about Solr, I'll assume it's non-transactional.
In that case, start a transaction in Oracle database and make changes. Then make the matching changes in Solr. If the Solr changes succeed, commit the Oracle transaction; if not, roll it back.
It's not perfect by any means but you're using the transactional strength of one element to make up for the deficiencies of the other.