JDBC Connection URL for Embedded Derby in Webapp

I have a derby database that is deployed with my webapp on WEB-INF / classes / myDb

Why should my jdbc.connection url connect so that I can write to the database?

I'm trying to

jdbc:derby:myDb;

and he cannot find the database. I need to be able to modify the database. If I set classpath: myDb, it will find it, but unfortunately it is read only for derby documents.

+5
source share
1 answer

I solved this by setting my jdbc connection url at runtime and using:

        StringBuilder derbyUrl = new StringBuilder("jdbc:derby:");
        derbyUrl.append(servletContext.getRealPath("/"));
        derbyUrl.append("/WEB-INF/classes/myDb;");
        dataSource.setUrl(derbyUrl.toString());
+4
source

All Articles