JDBC: Does call to rollback() method have effect only if call to commit() method does not succeed?

When you call commit(), you complete/close the current transaction. Thus, since rollback() undoes any changes in the current transaction (as per the javadoc), it will effectively do nothing.


Is con.rollback() has effect only if con.commit not succeeded?

YES And It also has effect if you call it before con.commit . And prerequisite is that autocommit mode of connection should be false using con.setAutoCommit(false)
Any transaction that you make in database using DML SQL queries using JDBC with con.setAutoCommit(false) is not commited to database until con.commit() is called. The latest commited transaction that you make in database acts as the savepoint for that connection. When you call con.rollback() all transaction that you have done after that savepoint is undone. Also if some exception occurs while calling con.commit(), it means that transactions are not saved in database. It is a good practice to call con.rollback() in catch statement if con.commit() fails.