I'm trying to start in memory HSQLDBs inside a webapp. These are meant as transient DBs, and I can't use JavaDB. I can never open a connection once HSQLDB is started. If you create a Webapp maven project in Netbeans and then add these to it. My hsqldb 1.8.0.10 jar is in my domain lib/ext. Once deployed, I tested the webservice, submitting "start" to it, then tried to connect to the now running DB using the Services->Database->HSLQDB connection, but it never connects.
Any ideas?
Maven pom.xml
[code]
<project xmlns="
http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ciminc</groupId>
<artifactId>Maven-Web</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven-Web JEE5 Webapp</name>
<url>
http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>webservices-rt</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>localhost_8080/Maven-Web/ProtoWebServiceService.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>${project.build.directory}/jaxws/stale/ProtoWebServiceService.stale</staleFile>
</configuration>
<id>wsimport-generate-ProtoWebServiceService</id>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<configuration>
<sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
<xnocompile>true</xnocompile>
<verbose>true</verbose>
<extension>true</extension>
<catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<webResources>
<resource>
<directory>src</directory>
<targetPath>WEB-INF</targetPath>
<includes>
<include>jax-ws-catalog.xml</include>
<include>wsdl/**</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
<finalName>Maven-Web</finalName>
</build>
<properties>
<netbeans.hint.deploy.server>J2EE</netbeans.hint.deploy.server>
</properties>
</project>
[/code]
Web service to start it
[code]
@WebService
public class ProtoWebService {
@WebMethod
public String webProcedure(String arg) {
if (arg.equals("start"))
EmbeddedDatabase.startEmbeddedDb();
else
EmbeddedDatabase.stopEmbeddedDb();
return arg;
}
}
[/code]
EmbeddedDatabase
[code]
public class EmbeddedDatabase {
private enum Settings {user, password, driver, url, dialect};
private static final Map<Settings,String> mobileSettings = new EnumMap<Settings,String>(Settings.class);
private static Server mobileServer;
static {
mobileSettings.put(Settings.user, "mobileRepo");
mobileSettings.put(Settings.password, "mobileRepo");
mobileSettings.put(Settings.driver, "org.hsqldb.jdbcDriver");
mobileSettings.put(Settings.url, "jdbc:hsqldb:hsql://localhost:10023/mobileRepo");
mobileSettings.put(Settings.dialect, "org.hibernate.dialect.HSQLDialect");
}
public static void startEmbeddedDb() {
mobileServer = new Server();
String portStr = mobileSettings.get(Settings.url).substring(
mobileSettings.get(Settings.url).indexOf("localhost:")+"localhost:".length(),
mobileSettings.get(Settings.url).indexOf("/", mobileSettings.get(Settings.url).indexOf("localhost:")+1));
mobileServer.setPort(Integer.parseInt(portStr));
mobileServer.putPropertiesFromString("database.0=mem:" +
mobileSettings.get(Settings.url).substring(mobileSettings.get(Settings.url).lastIndexOf("/") + 1));
mobileServer.putPropertiesFromString("dbname.0=" + mobileSettings.get(Settings.user));
mobileServer.setNoSystemExit(true);
mobileServer.start();
}
public static void stopEmbeddedDb() {
mobileServer.shutdown();
mobileServer = null;
}
[/code]
[Message sent by forum member 'ciminc']
http://forums.java.net/jive/thread.jspa?messageID=475407