Re: Can the embedded JDBC driver and the client JDBC driver co-exist?

2017-08-13 Thread Bryan Pendleton
Excellent news! Thanks for digging down to uncover the source of the
problem, and thanks for sharing your discoveries with us.

I know very little about pax-jdbc, but it seems like useful software; it
would be nice if it cleanly supported both the Embedded and Client-Server
driver configurations of Derby.

Perhaps you could forward your findings on to the pax-jdbc community, to
see if they think it might be possible to enhance their software?

In the meantime, it's great to hear that you have a solution that is
working for you.

bryan


Re: Can the embedded JDBC driver and the client JDBC driver co-exist?

2017-08-13 Thread Steinar Bang
> Bryan Pendleton :

> Anyway, yes, please try to figure out if you have any CLASSPATH conflicts,
> and please do let us know the results of your investigations!

The reason for my problems turned out to be quite simple.

I'm using the pax-jdbc DerbyDataSourceFactory in my derby database
bundle, so I was using that class in my unit test as well, assuming it
would be able to create the correct kind of data source, depending on
the JDBC URL.

However, when I looked at the source of the
DerbyDataSourceFactory.createDataSource() method, it looked like this:

public DataSource createDataSource(Properties props) throws SQLException {
EmbeddedDataSource ds = new EmbeddedDataSource();
setProperties(ds, props);
return ds;
}

...and an EmbeddedDataSource won't be able to create a client
connection... or so I think...?

So instead I created a client datasource directly, and that worked fine:
boolean createUkelonnDatabase = true;
ClientConnectionPoolDataSource dataSource = new 
ClientConnectionPoolDataSource();
dataSource.setServerName("localhost");
dataSource.setDatabaseName("ukelonn");
dataSource.setPortNumber(1527);
if (createUkelonnDatabase) {
dataSource.setCreateDatabase("create");
}
PooledConnection connect = dataSource.getPooledConnection();

With this connection, Liquibase can do its thing, and set up the schema
and data in the server.

Thanks again!