Hi,

I am trying to do a database connectivity in my android emulator, the
problem is i am doing a servlet program that includes a sqlite
connectivity in it.

After compiling the java files,generating the classes.dex, I am adding
META-INF and classes.dex into a classes.zip file with the respective
jars in the lib directory.Later a war file is generated from (WEB-
INF,META-INF,index.html & the database file).The war is then uploaded.

But when i download the war file and run it from the i-jetty server, I
am getting the following error: "org.sqlite.jdbc
java.lang.ClassNotFound Exeption".

The jars have been uploaded in the android emulator by an application
written in an activity class along with the respective database i am
trying to work on.

It is working properly on the Jetty server with the class paths set
with the jars and classes,but not on the I-Jetty server in the phone.

Eventually the I-Jetty server is able to run all servlet programs that
doesn't include a database connectivity.

I have tried to do the database connectivity with hsqldb database but
the result is the same.

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

try{
         out.println("<html>"+
         "<head>"+
         "<title>DataBase</title>"+
         "</head>"+
         "<body>"+
         "<h1>DataBase tbl_countries : </h1>");
         Class.forName("org.sqlite.JDBC");
         //Class.forName("SQLite.JDBCDriver").newInstance();
         Connection conn
=DriverManager.getConnection("jdbc:sqlite:webapps/DbTest/
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, "Australia");
         prep.addBatch();
         prep.setString(1, "Srilanka");
         prep.addBatch();
         prep.setString(1, "USA");
         prep.addBatch();
         conn.setAutoCommit(false);
         prep.executeBatch();
         conn.setAutoCommit(true);
         out.println("<table border=1>");
         out.println("<tr>");
         out.println("<th><b>id</b></th>");
         out.println("<th><b>country_name</b></th>");
         out.println("</tr>");
         ResultSet rs = stat.executeQuery("select * from
tbl_countries;");
         while (rs.next())
                        {
                             out.println("<tr>");
                             out.println("<td>"+rs.getString("id")+"</
td>");
 
out.println("<td>"+rs.getString("country_name")+"</td>");
                             out.println("</tr>");
                        }
         rs.close();
         conn.close();
       }
       catch(Exception e)
       {
            out.println("<h2>"+e.getMessage()+"</h2>");
            String str=e.toString();
            out.println("<h2>"+str+"</h2>");
        }
       out.println("</table></body></html>");
  }

Thanks,
Ritam Roy Choudhury

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to