Select Page

Is there a way to mock a jdbc connection by reading from the DBUnit XMLDataSet? I’m asking if there’s a way to establish a jdbc connection, using an XML file as the data source.

Connection jdbcConnection = DriverManager.getConnection(”jdbc:3RD_PARTY_JAR:XML:C:\test.xml”);
// create a Statement object to execute the query with
Statement stmt = conn.createStatement();
// execute a query
ResultSet rs = stmt.executeQuery(“SELECT * FROM resources”);

where the “C:\test.xml” is an XML file, such as a DBUnit data set.

I’ve located a tool called stelsxml (, which does just that. I’m open to using this tool, albeit a non open source commercial tool, a cheaply priced one at that. Although its scope of data types seems very limited (no SMALLINT, BOOLEAN etc), stelsxml seems like the right tool for the job and is really quite clean. Simply replacing the jdbc url in our getConnection(url) call and replacing the class loaded through Class.forName(string) is all I’ve had to change so far. I’m using the freeware version right now and would likely have to retrieve all the SMALLINTs and BOOLEANs as String datatypes and then perform some conversions.

Just throwing this out there … Does anyone know of a tool I can use to establish a jdbc connection with an XML data source? This would be similar to HSQLDB, requiring only a simple jar and working with XML sources (and perhaps a schema definition file).