Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-24-2009, 12:15 AM
Member
 
Join Date: Dec 2008
Posts: 30
Rep Power: 0
tomiu is on a distinguished road
Unhappy can't load the driver (hsqldb)
hi,

i have a strange problem..this code worked well until today..i haven't changed anything so i dont know why doesn't work anymore...

Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class TestDemobase {
    static String database = "/bsp/database";
    static String sql = "SELECT * FROM Bookmarks";
	static String sql1 = "SELECT url FROM Bookmarks";
	static String sql2 = "INSERT INTO Bookmarks VALUES('Pythoni', 'www.pythoni.com');CHECKPOINT";
    static Connection connection;

    public static void main(String[] args) throws Exception {
	System.out.println("TestDemobase 1\n");	
	

	Class.forName("org.hsqldb.jdbcDriver");

	 
	connection = DriverManager.getConnection("jdbc:hsqldb:" + database, "sa", "");

	    Statement statement = null;
        ResultSet resultSet = null;

        statement = connection.createStatement();
        resultSet = statement.executeQuery(sql);

	while (resultSet.next()) {
	    System.out.println(resultSet.getString("title") + " (" +
			       resultSet.getString("url") + ")");
	    
	}
	
	System.out.println("\nTestDemobase 2\n");
	resultSet = statement.executeQuery(sql1);

	while (resultSet.next()) {
	    System.out.println(" (" +resultSet.getString("url") + ")");
	    
	}
	
	System.out.println("\nTestDemobase 3\n");
	resultSet = statement.executeQuery(sql2);
	//statement.executeUpdate("INSERT INTO Bookmarks " + "VALUES('Pythoni', 'www.pythoni.com')");


	System.out.println("TestDemobase 1\n");	
	resultSet = statement.executeQuery(sql);

	while (resultSet.next()) {
	    System.out.println(resultSet.getString("title") + " (" +
			       resultSet.getString("url") + ")");
	    
	}
	resultSet.close();
	statement.close();
	connection.close();
    }
}
and the error message:

Code:
TestDemobase 1

Exception in thread "main" java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver
	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)
	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Unknown Source)
	at TestDemobase.main(TestDemobase.java:17)

thx in advance for ur help
tomiou
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 05-24-2009, 03:36 AM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
Default
Well something must have changed. The classloader can't find the driver classes any more.
__________________
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-28-2009, 08:39 PM
Member
 
Join Date: Dec 2008
Posts: 30
Rep Power: 0
tomiu is on a distinguished road
Default
but i didn't change anything...i just dont know why the code worked before and doesn't work anymore...the code compiles fine with no error, but when i run it the classloader can't find the driver...

Last edited by tomiu; 05-28-2009 at 08:43 PM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-28-2009, 09:47 PM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
Default
Then the driver files got moved or you changed your classpath or execution method. Things don't magically become broken for no reason.
__________________
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-29-2009, 03:41 AM
CJSLMAN's Avatar
Moderator
 
Join Date: Oct 2008
Location: Mexico
Posts: 1,159
Rep Power: 3
CJSLMAN is on a distinguished road
Default It's a dang conspiracy !!!
Quote:
Things don't magically become broken for no reason.
Yes, they do. That's why Gremlins were invented... they do this kind of stuff all the time and sometimes they even buddy up with Murphy to make things worse.

CJSL
__________________
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Last edited by CJSLMAN; 05-29-2009 at 04:08 PM. Reason: add smilely face
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-29-2009, 05:21 AM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
Default
Whether it was you or the Gremlins that changed something, something still got changed.
__________________
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 05-29-2009, 11:47 PM
Member
 
Join Date: Dec 2008
Posts: 30
Rep Power: 0
tomiu is on a distinguished road
Default
Originally Posted by OrangeDog View Post
Whether it was you or the Gremlins that changed something, something still got changed.
i still can't find what got changed...all i did was: SHUT DOWN the PC and the next day showed this error...i didn'T install new software, i didn't deinstalled anything...i checked hsqdlb.jar is in my classpath, so no change there too...
i'll post this problem in other forums and if i find the solution i'll post it here too
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 06-10-2009, 12:23 AM
Member
 
Join Date: Sep 2008
Posts: 16
Rep Power: 0
venkatallu is on a distinguished road
Default
i think ur driver class(hsql.jar file) has chaged its place.if s, u have to make changes in ur classpath..that is the main problem .
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
load driver in javaDB kulangotski New To Java 1 02-20-2009 08:15 PM
Configure HSQLDB in RedHatEnterpriseLinux 4 vrk Database 0 02-13-2009 07:44 AM
PostgreSQL driver bugger Database 3 01-11-2008 10:45 AM
Help with JDBC driver Daniel Database 2 07-03-2007 09:16 PM
Oracle Driver softy Database 1 07-02-2007 01:20 AM


All times are GMT +2. The time now is 05:53 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org