Just finished a project that did this using Derby with Hibernate a couple of days ago. (He works with Derby in the same JVM.)
As I understand it, when you use the Embedded driver, by default it starts the database instance as part of the driver and as long as you hang on the connection in which the database is running. But for Hibernate, he likes to have DataSourceone that should be the source of the union data.
The above answer is correct, itβs actually good to run Derby as a network database server, even if your in the same JVM. You can still use the built-in JDBC driver, which seems to know when the database you are connecting to is online and is configured accordingly. (It also allows you to use a third-party tool to connect to the database, view and edit data and circuits during its operation, which are very convenient for debugging.)
System.setProperty("derby.system.home", applicationHome);
NetworkServerControl serverControl = new NetworkServerControl(InetAddress.getByName(m_address),port);
serverControl.start(new PrintWriter(System.out, true));
DataSource JNDI. Hibernate , , JNDI.
EmbeddedConnectionPoolDataSource40 dataSource = new EmbeddedConnectionPoolDataSource40();
dataSource.setDatabaseName(databaseName);
dataSource.setUser(username);
dataSource.setPassword(password);
EmbeddedConnectionPoolDataSource40 - DataSource DataSource, , . Apache Commons DBCP , DataSource EmbeddedConnectionPoolDataSource40.