Results 1 to 2 of 2
  1. #1
    sahnse is offline Member
    Join Date
    Dec 2009
    Posts
    1
    Rep Power
    0

    Default How to convert Sqlite database table into XML file

    I need help on this.
    I need to I need to query an sqlite database and export a table from there into an xml file??

    The two libraries I'm using are JDOM and SQLite.

    I can establish a connection but then I get an error message saying that the file is encrypted>???

    Here is what I have so far:

    private void ConvertBtnActionPerformed(java.awt.event.ActionEve nt evt) {
    // When convert button is pressed, connection to database will be made
    // file will be converted
    Connection connection = null;
    ResultSet resultSet = null;
    Statement statement = null;

    try {
    Class.forName("org.sqlite.JDBC");
    connection = DriverManager.getConnection("jdbc:sqlite:C:\\Users \\Sun\\Desktop\\finalexam2009.db");
    statement = connection.createStatement();
    //query employee table for all records
    //create xml using jdom libraries

    resultSet = statement.executeQuery("SELECT EMPNAME FROM EMPLOYEE");

    while (resultSet.next()) {
    System.out.println("EMPLOYEE NAME:"
    + resultSet.getString("EMPNAME"));
    }
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    try {
    resultSet.close();
    statement.close();
    connection.close();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    //when conversion is complete, show a message dialog box saying that conversion is complete
    }


    I don't know what to do next, have been looking around everywhere.

    Thank You.

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    if you are getting a database is encrypted error ?
    that must mean the database has been set up to use password or security key protection.
    By default sqlite databases are not password protected, so you would need to find out what password was used to set this up on this database.

    Would you be able to use a tool to create a new test sqlite database and fill it with a couple test tables, and then use this connector to try to read from that ?

Similar Threads

  1. How to convert a table
    By gilbertsavier in forum JDBC
    Replies: 0
    Last Post: 07-17-2009, 07:25 AM
  2. Replies: 2
    Last Post: 02-11-2009, 04:43 AM
  3. Replies: 0
    Last Post: 01-20-2009, 03:28 PM
  4. Updating database table from JTable
    By yesjava in forum New To Java
    Replies: 1
    Last Post: 08-16-2008, 10:16 PM
  5. Replies: 0
    Last Post: 02-09-2008, 08:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •