Results 1 to 8 of 8
  1. #1
    tomiu is offline Member
    Join Date
    Dec 2008
    Posts
    32
    Rep Power
    0

    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...

    Java 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:

    Java 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

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    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

  3. #3
    tomiu is offline Member
    Join Date
    Dec 2008
    Posts
    32
    Rep Power
    0

    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.

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    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

  5. #5
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default It's a dang conspiracy !!!

    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
    Last edited by CJSLMAN; 05-29-2009 at 04:08 PM. Reason: add smilely face
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  6. #6
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    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

  7. #7
    tomiu is offline Member
    Join Date
    Dec 2008
    Posts
    32
    Rep Power
    0

    Default

    Quote 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

  8. #8
    venkatallu is offline Member
    Join Date
    Sep 2008
    Posts
    16
    Rep Power
    0

    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 .

Similar Threads

  1. load driver in javaDB
    By kulangotski in forum New To Java
    Replies: 1
    Last Post: 02-20-2009, 08:15 PM
  2. Replies: 0
    Last Post: 02-13-2009, 07:44 AM
  3. PostgreSQL driver
    By bugger in forum JDBC
    Replies: 3
    Last Post: 01-11-2008, 10:45 AM
  4. Help with JDBC driver
    By Daniel in forum JDBC
    Replies: 2
    Last Post: 07-03-2007, 09:16 PM
  5. Oracle Driver
    By softy in forum JDBC
    Replies: 1
    Last Post: 07-02-2007, 01:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •