package dbunit.helpers;

import java.io.FileWriter;
import java.sql.Connection;
import java.sql.DriverManager;

import org.dbunit.database.DatabaseConnection;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlWriter;
import org.dbunit.dataset.xml.XmlDataSetWriter;

import sklep.baza.Baza;

public class DumpDB {
	public static void main(String[] args) {
		try {
			Class.forName("org.sqlite.JDBC");
			Connection jdbcConnection = DriverManager.getConnection(Baza.url);
			
			DatabaseConnection dbc = new DatabaseConnection(jdbcConnection);
			IDataSet dataSet = dbc.createDataSet();
			XmlDataSetWriter writer = new XmlDataSetWriter(new FileWriter("dane.xml"));
			//FlatXmlWriter writer = new FlatXmlWriter(new FileWriter("dane.xml"));
			writer.write(dataSet);
			dbc.close();
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}
