db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: java.sql.SQLException: No suitable driver
Date Fri, 28 May 2010 21:53:41 GMT
On 28.05.2010 18:44, Marcin Krol wrote:
> Hello everyone,
> I'm trying to use Derby here as embedded database in our test 
> automation framework (that deploys itself on the remote endpoint and 
> executes some Java classes to test functionality of the product).
> Code:
> private void createDerbyConnection() throws ClassNotFoundException, 
> SQLException
> {
>     Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
>     String dburl = "jdbc:derby:DerbyDB;create=true";
>     derbyconn = DriverManager.getConnection(dburl);
>     derbyconn.setAutoCommit(false);
>     derbyst = derbyconn.createStatement();
> }

Hi Marcin,

Sorry for this vey vague answer, but could this have to do with 
Is the framwork you are using doing anything explicit about classloaders?

There is some classloader sensitive code in DriverManager.
Not sure in which context I stumbled over this, but I may have worked 
around the issue by using the Class.forName() method that takes a 
ClassLoader argument. Now, if this is the problem and the proposed fix 
is sound, you just have to figure out which classloader to use when 
loading the driver class :)


> Now, the weird thing is that when the same class is using Derby in 
> standalone program (ran e.g. on Linux) *on the same host*, or in 
> Eclipse on my laptop, it all runs fine - I can connect to the db and 
> operate on it all right.
> It's only when I deploy the thing remotely, I get exception 
> "java.sql.SQLException: No suitable driver" on line:
> derbyconn = DriverManager.getConnection(dburl);
> Note: the EmbeddedDriver jdbc class is most probably loaded fine, 
> which is reinforced by the fact that if I delete derby.jar from 
> classpath I get ClassNotFoundException.
> Some people on the net suggested that this exception is being caused 
> by wrong db url, but I can't see what's possibly wrong with my db url. 
> I was under impression that this is correct dburl for embedded derby 
> driver which should be in derby.jar.

View raw message