How to convert Sqlite database table into XML file
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: How to convert Sqlite database table into XML file

  1. #1
    Join Date
    Dec 2009

    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 {
    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 ( {
    System.out.println("EMPLOYEE NAME:"
    + resultSet.getString("EMPNAME"));
    } catch (Exception e) {
    } finally {
    try {
    } catch (Exception e) {
    //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
    Join Date
    Jul 2005
    Currently in Mexico City

    Re: How to convert Sqlite database table into XML file

    Do you get the expected results from the query? I mean, does this program work?

    If yes, then just write the xml as you would write any other text file using BufferedWriter. Here is an example:

    Depending on the case you could probably simplify the approach by writing some tools for the specific tasks:
    Last edited by Xeel; December 21st, 2009 at 11:52 AM.
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that Iím 64-bit and my blanket is 32-bit and I couldnít cover myself with it, so Iíve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from:

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center