Commit ba603bab authored by Michael Schimpelsberger's avatar Michael Schimpelsberger
Browse files

Konfiguration server für programmierstart teil 2;

TCP db sollte jetzt funktionieren
parent f2e4104e
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="at.jku.ce">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="at.jku.ce"/>
<property name="java-output-path" value="/at.jku.ce/target/classes"/>
</wb-module>
</project-modules>
......@@ -75,22 +75,12 @@
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.8-b01</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2-promoted-b65</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat -->
<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
......
......@@ -8,10 +8,11 @@ import java.nio.file.Paths;
public class DaoParam {
protected static final String DRIVER="org.h2.Driver";
protected static final String USER="sa";
protected static final String PASSWORD="";
protected static final String JDBC_URL="jdbc:h2:"+getDbPath();
public static final String DRIVER="org.h2.Driver";
public static final String USER="sa";
public static final String PASSWORD="";
public static final String JDBC_URL="jdbc:h2:"+getDbPath();
public static final String TCP_PORT="9192";
private static String getDbPath() {
......
package university.at.jku.ce.init;
import java.sql.SQLException;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.h2.tools.Server;
import university.at.jku.ce.dao.DBInitializerDao;
import university.at.jku.ce.dao.h2dao.DaoParam;
import university.at.jku.ce.dao.h2dao.H2DBInitializerDao;
public class MyAppServletContextListener implements ServletContextListener{
DBInitializerDao dao=new H2DBInitializerDao();
Server server;
@Override
public void contextInitialized(ServletContextEvent sce) {
try {
server = Server.createTcpServer(new String[] {"-tcpPort",DaoParam.TCP_PORT,"-tcp","-tcpAllowOthers"}).start();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (!dao.isValidDatabase()) {dao.initDatabase();
System.out.println("Initializing Database");
}
......@@ -23,6 +35,7 @@ else {System.out.println("No Database initialization required");}
@Override
public void contextDestroyed(ServletContextEvent sce) {
// TODO Auto-generated method stub
server.stop();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment