CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Dec 2009
    Posts
    1

    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
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    568

    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: http://www.javapractices.com/topic/TopicAction.do?Id=42

    Depending on the case you could probably simplify the approach by writing some tools for the specific tasks: http://www.javazoom.net/services/new...eneration.html
    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: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    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
  •  





Click Here to Expand Forum to Full Width

Featured