Error java.sql.SQLException: ORA-01555 Hey I am running a select * from  query against ORACLE database. So is there a way we can avoid this kind of error. 

The query is fetching a large amount of data. It can take weeks to get that amount of that.

java.sql.SQLException: ORA-01555: snapshot too old: rollback segment number 50 with name "_SYSSMU50_1322772922$" too small

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
at oracle.jdbc.driver.T4CStatement.fetch(T4CStatement.java:1018)
at oracle.jdbc.driver.OracleResultSetImpl.close_or_fetch_from_next(OracleResultSetImpl.java:291)
at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:213)
This may be helpful: http://www.dba-oracle.com/t_ora_01555_snapshot_old.htm

Sorry, I know this belongs in the comments section, but SO won't let me comment until my rating is above 50 :(.