Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB Unit

Status
Not open for further replies.

dexter195

Programmer
Jun 18, 2003
220
EU
Hi,

Can anyone see whats wrong with this.
Im using DB Unit with HSQL Memory based database but I'm having trouble trying to get it to recognise the driver.

I have used this driver with another class to connect to the database, run queries etc and it works fine and its the same as in examples on the internet.

Thanks for the help
Dexter

Code:
protected IDatabaseConnection getConnection() throws Exception
	{
		String driver = "org.hsqldb.jdbcDriver";
	    String protocol = "jdbc:hsqldb:mem:";
	    
	    try
	    {
		    Class driverClass = Class.forName("org.hsqldb.jdbcDriver");
	        Connection jdbcConnection = DriverManager.getConnection("jdbc:hsqldb:mem:sample", "sa", "");
	        return new DatabaseConnection(jdbcConnection);
	    }
	    
	    catch (Exception e)
	    {
	    	e.printStackTrace();
	    }

		return null;	
	}

protected IDataSet getDataSet() throws Exception
	{
	
		String[] tableNames = {"TestTable1", "TestTable2"};
		
		 IDataSet loadedDataSet = getConnection().createDataSet(tableNames); 
		
		return loadedDataSet ;
	}

Stack Trace
Code:
org.hsqldb.jdbcDriver

java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at com.distocraft.dc5000.dwhm.DatabaseTest.getConnection(DatabaseTest.java:140)
at org.dbunit.DatabaseTestCase.newDatabaseTester(DatabaseTestCase.java:66)
at org.dbunit.DatabaseTestCase.getDatabaseTester(DatabaseTestCase.java:79)
at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:116)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top