Note that there are some explanatory texts on larger screens.

plurals
  1. POError using DBunit to export a DB "java.lang.NoClassDefFoundError: org/dbunit/database/IDatabaseConnection"
    text
    copied!<p>I've got the following java code, which is giving the error below:</p> <pre><code>import java.io.File; import java.io.FileOutputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import org.dbunit.database.DatabaseConnection; import org.dbunit.database.IDatabaseConnection; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.xml.FlatXmlDataSet; public class export { public static void main(String[] args) throws Exception { // database connection Class.forName("net.sourceforge.jtds.jdbc.Driver"); Connection jdbcConnection = DriverManager.getConnection( "jdbc:jtds:sqlserver://localhost:1433/exampleDB", "sa", "vista1"); IDatabaseConnection connection = new DatabaseConnection(jdbcConnection); // full database export IDataSet fullDataSet = connection.createDataSet(); FlatXmlDataSet.write(fullDataSet, new FileOutputStream("full.xml")); } } </code></pre> <p><strong>Error:</strong></p> <p>$ java export</p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/dbunit/database/IDatabaseConnection Caused by: java.lang.ClassNotFoundException: org.dbunit.database.IDatabaseConnection at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) Could not find the main class: export. Program will exit. </code></pre> <p>The name of the java file being compiled is <code>export.java</code> and the name of the compiled file is <code>export.class</code>, and I've put the <code>dbunit-2.4.8.jar</code> and <code>jtds-1.2.5.jar</code> files in to the same folder as <code>export.java</code> and <code>export.class</code>; and I'm compiling export.java with the following cmd:</p> <pre><code>$ javac -cp "dbunit-2.4.8.jar;jtds-1.2.5.jar" export.java </code></pre> <p>Any idea what I'm doing wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload