Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection with Sqlite in android through Servlet

I am trying to do a database connectivity in my android emulator, the problem is i am doing a servlet program that includes sqlite connectivity in it, but when i download the war file and run it from the jetty server, I am getting the following error: "org.sqlite.jdbc java.lang.classnotfound exeption"

I have been trying for days but could'nt get this database connectivity from my android emulator working, Could someone please help me, Here is my code,

        Class.forName("org.sqlite.JDBC");
            Connection conn=DriverManager.getConnection("jdbc:sqlite:webapps/DbTes/TestData.db");
        Statement stat=conn.createStatement();
        stat.executeUpdate("drop table if exists tbl_countries;");
        stat.executeUpdate("create table tbl_countries (id INTEGER PRIMARY KEY AUTOINCREMENT, country_name TEXT);");
        PreparedStatement prep = conn.prepareStatement("insert into tbl_countries(country_name) values (?);");
        prep.setString(1, "a");

        prep.addBatch();
        prep.setString(1, "b");
        prep.addBatch();
        prep.setString(1, "c");
        prep.addBatch();
            conn.setAutoCommit(false);
        prep.executeBatch();
        conn.setAutoCommit(true);"

Thanks...

like image 282
user1270988 Avatar asked Mar 15 '12 09:03

user1270988


1 Answers

Using the jetty, send the information to the Mobile in any format such as JSON or XML. Parse data in the mobile application end. Create the database and save it using the SQLITE.

like image 185
Jabeer Avatar answered Oct 05 '22 13:10

Jabeer