Integrating rollbar into java application

Rollbar is an error tracking and monitoring application.


Whenever an exception is happing in the java code, it can be logged in the rollbar to view the error log.

POM.XML:
<dependency> 
   <groupId>com.rollbar</groupId>   
   <artifactId>rollbar-java</artifactId>
    <version>1.1.0</version> 
   <exclusions> 
       <exclusion>
            <artifactId>jcl-over-slf4j</artifactId>
            <groupId>org.slf4j</groupId> 
       </exclusion>
        <exclusion>
            <artifactId>slf4j-api</artifactId>
            <groupId>org.slf4j</groupId> 
       </exclusion>
    </exclusions>
</dependency>

Rollbar.java :

package utils;
import com.rollbar.notifier.Rollbar;import com.rollbar.notifier.config.Config;
import java.net.InetAddress;
import static com.rollbar.notifier.config.ConfigBuilder.withAccessToken;
public class rollbar {
    private static Rollbar rollbar;    private static void init() {
        try {
            Config config = withAccessToken(API KEY)
                    .environment("Testing Framework")
                    .platform(InetAddress.getLocalHost().getHostName())
                    .codeVersion("1.0")
                    .build();            rollbar = Rollbar.init(config);        }
        catch (Exception e)
        {
            e.printStackTrace();            log.exception("Rollbar:init() "+"\n"+e.getStackTrace());
        }
    }

    public static void exceptionLog(Exception exception, String exceptionDetils){
        init();        rollbar.error(exception,exceptionDetils);    }

}



Now in your program, you can include the static method in try and catch block to log the details:

Rollbar.exceptionLog(e,"Exception details");


Convert resultset object to list of map

Convert the resultset object to list of map In some cases, while we doing API automation, we need to fetch the value from the DB and hav...