AnsweredAssumed Answered

Connecting and querying sqlite

Question asked by MallikarjunMelagiri on Nov 23, 2015

Hi all,


I'm trying to hit a REST service which returns the contents in an SQLite format. I'm trying to use "Save Property Value to File" filter in DevTest to save the response contents to a file called MyDb.sqlite


I later open this file in a JSR-223 script step, and try to connect to it and query the table in it (.sqlite file is like a DB schema which has multiple tables in it). With the following code:


import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;


Connection conn = null;

Statement stmt = null;

ResultSet rSet = null; 


try {


      conn = DriverManager.getConnection("jdbc:sqlite:C:\\CA\\MyDb.sqlite");

      System.out.println("Database is: "+conn.getMetaData().getDatabaseProductName());

      stmt = conn.createStatement(); 

      rSet = stmt.executeQuery("SELECT * FROM MyTable");

      while ( { 


                     + rSet.getString("BRCOMPANY")); 




} catch ( Exception e ) {

      System.err.println( e.getClass().getName() + ": " + e.getMessage() );



//System.out.println("Opened database successfully");


I'm getting the following error:

ERROR - java.sql.SQLException: [SQLITE_CORRUPT]  The database disk image is malformed (database disk image is malformed)


Then I hit the service from Chrome REST client extension and compared the response content with that of the .sqlite file that my test script saved. and I found differences.


I See that LISA is adding extra NUL junk characters to the file.


How can i configure it to save the exact contents returned from the service response? I know that it has to do something with response headers, content-type etc. But not sure how to configure it to get the correct response saved to my .sqlite file.