Commit 32f5b52f authored by Michael Schimpelsberger's avatar Michael Schimpelsberger
Browse files

- Schnittstelle Student erweitert

- H2 Datenbank eingebunden (aktuell nur über absoluten Pfad möglich)
- TextDaos entfernt
parent 643cea84
......@@ -6,16 +6,11 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
......@@ -29,5 +24,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="src/main/webapp/WEB-INF/lib/h2-1.4.197.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
......
eclipse.preferences.version=1
org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.8"/>
<installed facet="jst.web" version="2.5"/>
<installed facet="jst.jaxrs" version="2.1"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.8"/>
</faceted-project>
DROP TABLE subject CASCADE CONSTRAINTS;
DROP TABLE student CASCADE CONSTRAINTS;
DROP TABLE study CASCADE CONSTRAINTS;
-- Create Tables
CREATE TABLE student (matrnr INTEGER PRIMARY KEY, firstname VARCHAR2(200), lastname VARCHAR2(200));
CREATE TABLE study (studyid INTEGER PRIMARY KEY, name VARCHAR(40));
CREATE TABLE subject (
studyId INTEGER,
subjectid INTEGER,
name VARCHAR2(40),
ects INTEGER,
PRIMARY KEY (studyid, subjectid),
FOREIGN KEY (studyId) REFERENCES study(studyId) ON DELETE CASCADE
);
CREATE TABLE inscription(
matrnr INTEGER,
studyid INTEGER,
ins_date DATE,
FOREIGN KEY (studyid) REFERENCES study(studyid),
FOREIGN KEY (matrnr) REFERENCES student(matrnr),
PRIMARY KEY (matrnr, studyid)
);
-- Insert Data sutdent
INSERT INTO student(matrnr, firstname,lastname) values(1, 'Andres', 'Iniesta');
INSERT INTO student(matrnr, firstname,lastname) values(2, 'Lionel', 'Messi');
INSERT INTO student(matrnr, firstname,lastname) values(3, 'David', 'Silva');
INSERT INTO student(matrnr, firstname,lastname) values(4, 'Luka', 'Modric');
INSERT INTO student(matrnr, firstname,lastname) values(5, 'Marcel', 'Hirscher');
INSERT INTO student(matrnr, firstname,lastname) values(6, 'Henrik', 'Kristoffersen');
INSERT INTO student(matrnr, firstname,lastname) values(7, 'Aksel Lund', 'Svindal');
INSERT INTO student(matrnr, firstname,lastname) values(8, 'Hermann', 'Maier');
-- Insert Data study
INSERT INTO study(studyId, name) values(1, 'Wirtschftsinformatik');
INSERT INTO study(studyId, name) values(2, 'Informatik');
INSERT INTO study(studyId, name) values(3, 'Mathematik');
INSERT INTO study(studyId, name) values(4, 'Physiotherapie');
INSERT INTO study(studyId, name) values(5, 'Gesundheits- und Krankenpflege');
INSERT INTO study(studyId, name) values(6, 'Sportwissenschaften');
-- Insert Data subject
INSERT INTO subject(studyid, subjectid, name, ects) values(1,1,'Communications Engineering',6);
INSERT INTO subject(studyid, subjectid, name, ects) values(1,2,'Grundlagen Softwareentwicklung',6);
INSERT INTO subject(studyid, subjectid, name, ects) values(1,3,'Vertiefung Softwareentwicklung',6);
INSERT INTO subject(studyid, subjectid, name, ects) values(2,1,'Softwareentwicklung 1',6);
INSERT INTO subject(studyid, subjectid, name, ects) values(2,2,'Softwareentwicklung 2',6);
INSERT INTO subject(studyid, subjectid, name, ects) values(2,3,'Elektronik',4);
INSERT INTO subject(studyid, subjectid, name, ects) values(3,1,'Algebra',3);
INSERT INTO subject(studyid, subjectid, name, ects) values(3,2,'Mathematik 1',3);
INSERT INTO subject(studyid, subjectid, name, ects) values(4,1,'Bewegungslehre',6);
INSERT INTO subject(studyid, subjectid, name, ects) values(4,2,'Trainingslehre',2);
INSERT INTO subject(studyid, subjectid, name, ects) values(4,3,'Spezifische Anatomie',2);
INSERT INTO subject(studyid, subjectid, name, ects) values(5,1,'Allgemeine Anatomie',3);
INSERT INTO subject(studyid, subjectid, name, ects) values(5,2,'Allgemeine Physiologie',3);
INSERT INTO subject(studyid, subjectid, name, ects) values(6,1,'Trainingslehre',6);
INSERT INTO subject(studyid, subjectid, name, ects) values(6,2,'Bewegungslehre',3);
INSERT INTO inscription(matrnr, studyid, ins_date) values (1,1,sysdate);
INSERT INTO inscription(matrnr, studyid, ins_date) values (1,2,sysdate);
INSERT INTO inscription(matrnr, studyid, ins_date) values (1,3,sysdate);
INSERT INTO inscription(matrnr, studyid, ins_date) values (2,1,sysdate);
INSERT INTO inscription(matrnr, studyid, ins_date) values (2,2,sysdate);
INSERT INTO inscription(matrnr, studyid, ins_date) values (3,3,sysdate);
\ No newline at end of file
2019-01-11 14:26:53 jdbc[3]: exception
org.h2.jdbc.JdbcSQLException: Unbekannter Datentyp: "PRIMARY"
Unknown data type: "PRIMARY"; SQL statement:
Create table Student (matrnr PRIMARY KEY, firstname NOT NULL, lastname NOT NULL) [50004-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.command.Parser.parseColumnWithType(Parser.java:4400)
at org.h2.command.Parser.parseColumnForTable(Parser.java:4215)
at org.h2.command.Parser.parseTableColumnDefinition(Parser.java:6662)
at org.h2.command.Parser.parseCreateTable(Parser.java:6570)
at org.h2.command.Parser.parseCreate(Parser.java:4615)
at org.h2.command.Parser.parsePrepared(Parser.java:380)
at org.h2.command.Parser.parse(Parser.java:335)
at org.h2.command.Parser.parse(Parser.java:307)
at org.h2.command.Parser.prepareCommand(Parser.java:278)
at org.h2.engine.Session.prepareLocal(Session.java:611)
at org.h2.engine.Session.prepareCommand(Session.java:549)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:217)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:1077)
at org.h2.server.web.WebApp.getResult(WebApp.java:1386)
at org.h2.server.web.WebApp.query(WebApp.java:1060)
at org.h2.server.web.WebApp$1.next(WebApp.java:1022)
at org.h2.server.web.WebApp$1.next(WebApp.java:1009)
at org.h2.server.web.WebThread.process(WebThread.java:165)
at org.h2.server.web.WebThread.run(WebThread.java:90)
at java.base/java.lang.Thread.run(Unknown Source)
2019-01-11 14:34:26 jdbc[3]: exception
org.h2.jdbc.JdbcSQLException: Feld "GEH" nicht gefunden
Column "GEH" not found; SQL statement:
Insert into Student(matrnr, firstname,lastname) values(2, Geh, Scheissn) [42122-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:150)
at org.h2.command.dml.Insert.prepare(Insert.java:314)
at org.h2.command.Parser.prepareCommand(Parser.java:283)
at org.h2.engine.Session.prepareLocal(Session.java:611)
at org.h2.engine.Session.prepareCommand(Session.java:549)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:217)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:1077)
at org.h2.server.web.WebApp.getResult(WebApp.java:1386)
at org.h2.server.web.WebApp.query(WebApp.java:1060)
at org.h2.server.web.WebApp$1.next(WebApp.java:1022)
at org.h2.server.web.WebApp$1.next(WebApp.java:1009)
at org.h2.server.web.WebThread.process(WebThread.java:165)
at org.h2.server.web.WebThread.run(WebThread.java:90)
at java.base/java.lang.Thread.run(Unknown Source)
2019-01-12 13:42:49 database: flush
org.h2.message.DbException: Allgemeiner Fehler: "java.lang.IllegalStateException: The file is locked: nio:C:/Users/Michael/development/workspace-ce5/at.jku.ce/data/Database.mv.db [1.4.197/7]"
General error: "java.lang.IllegalStateException: The file is locked: nio:C:/Users/Michael/development/workspace-ce5/at.jku.ce/data/Database.mv.db [1.4.197/7]" [50000-197]
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.message.DbException.convert(DbException.java:307)
at org.h2.mvstore.db.MVTableEngine$1.uncaughtException(MVTableEngine.java:95)
at org.h2.mvstore.MVStore.handleException(MVStore.java:2506)
at org.h2.mvstore.MVStore.panic(MVStore.java:383)
at org.h2.mvstore.MVStore.<init>(MVStore.java:364)
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2934)
at org.h2.mvstore.db.MVTableEngine$Store.open(MVTableEngine.java:155)
at org.h2.mvstore.db.MVTableEngine.init(MVTableEngine.java:100)
at org.h2.engine.Database.getPageStore(Database.java:2538)
at org.h2.engine.Database.open(Database.java:709)
at org.h2.engine.Database.openDatabase(Database.java:286)
at org.h2.engine.Database.<init>(Database.java:280)
at org.h2.engine.Engine.openSession(Engine.java:66)
at org.h2.engine.Engine.openSession(Engine.java:179)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:157)
at org.h2.engine.Engine.createSession(Engine.java:140)
at org.h2.engine.Engine.createSession(Engine.java:28)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:351)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:124)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:103)
at org.h2.Driver.connect(Driver.java:69)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:678)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
at university.at.jku.ce.h2dao.H2StudentDao.getAllStudents(H2StudentDao.java:37)
at university.at.jku.ce.service.StudentServiceImpl.getAllStudents(StudentServiceImpl.java:21)
at university.at.jku.ce.resource.StudentResource.getStudents(StudentResource.java:31)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:76)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:148)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:191)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:200)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:103)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:493)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:415)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:104)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:277)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268)
at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
at org.glassfish.jersey.internal.Errors.process(Errors.java:268)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1152)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: org.h2.jdbc.JdbcSQLException: Allgemeiner Fehler: "java.lang.IllegalStateException: The file is locked: nio:C:/Users/Michael/development/workspace-ce5/at.jku.ce/data/Database.mv.db [1.4.197/7]"
General error: "java.lang.IllegalStateException: The file is locked: nio:C:/Users/Michael/development/workspace-ce5/at.jku.ce/data/Database.mv.db [1.4.197/7]" [50000-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
... 74 more
Caused by: java.lang.IllegalStateException: The file is locked: nio:C:/Users/Michael/development/workspace-ce5/at.jku.ce/data/Database.mv.db [1.4.197/7]
at org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:870)
at org.h2.mvstore.FileStore.open(FileStore.java:173)
at org.h2.mvstore.MVStore.<init>(MVStore.java:350)
... 68 more
2019-01-12 13:43:45 jdbc[4]: exception
org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL Befehl "DROP TABLE STUDENT CASCADE CONSTRAINTS PURGE[*] "
Syntax error in SQL statement "DROP TABLE STUDENT CASCADE CONSTRAINTS PURGE[*] "; SQL statement:
DROP TABLE student CASCADE CONSTRAINTS PURGE [42000-197]
2019-01-12 13:57:45 jdbc[4]: exception
org.h2.jdbc.JdbcSQLException: Unbekannter Datentyp: "NOT"
Unknown data type: "NOT"; SQL statement:
CREATE TABLE student (matrnr INTEGER PRIMARY KEY, firstname VARCHAR2(200) NOT NULL, lastname NOT NULL) [50004-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.command.Parser.parseColumnWithType(Parser.java:4400)
at org.h2.command.Parser.parseColumnForTable(Parser.java:4215)
at org.h2.command.Parser.parseTableColumnDefinition(Parser.java:6662)
at org.h2.command.Parser.parseCreateTable(Parser.java:6570)
at org.h2.command.Parser.parseCreate(Parser.java:4615)
at org.h2.command.Parser.parsePrepared(Parser.java:380)
at org.h2.command.Parser.parse(Parser.java:335)
at org.h2.command.Parser.parse(Parser.java:307)
at org.h2.command.Parser.prepareCommand(Parser.java:278)
at org.h2.engine.Session.prepareLocal(Session.java:611)
at org.h2.engine.Session.prepareCommand(Session.java:549)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:217)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:1077)
at org.h2.server.web.WebApp.getResult(WebApp.java:1386)
at org.h2.server.web.WebApp.query(WebApp.java:1060)
at org.h2.server.web.WebApp$1.next(WebApp.java:1022)
at org.h2.server.web.WebApp$1.next(WebApp.java:1009)
at org.h2.server.web.WebThread.process(WebThread.java:165)
at org.h2.server.web.WebThread.run(WebThread.java:90)
at java.base/java.lang.Thread.run(Unknown Source)
2019-01-12 13:59:46 jdbc[4]: exception
org.h2.jdbc.JdbcSQLException: Tabelle "STUDY" besteht bereits
Table "STUDY" already exists; SQL statement:
CREATE TABLE study (studyid INTEGER PRIMARY KEY, name VARCHAR(40)) [42101-197]
2019-01-12 13:59:46 jdbc[4]: exception
org.h2.jdbc.JdbcSQLException: Tabelle "SUBJECT" besteht bereits
Table "SUBJECT" already exists; SQL statement:
CREATE TABLE subject (
studyId INTEGER,
subjectid INTEGER,
name VARCHAR2(40),
ects INTEGER,
PRIMARY KEY (studyid, subjectid),
FOREIGN KEY (studyId) REFERENCES study(studyId)
) [42101-197]
2019-01-12 14:05:14 database: flush
org.h2.message.DbException: Allgemeiner Fehler: "java.lang.IllegalStateException: The file is locked: nio:C:/Users/Michael/development/workspace-ce5/at.jku.ce/data/Database.mv.db [1.4.197/7]"
General error: "java.lang.IllegalStateException: The file is locked: nio:C:/Users/Michael/development/workspace-ce5/at.jku.ce/data/Database.mv.db [1.4.197/7]" [50000-197]
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.message.DbException.convert(DbException.java:307)
at org.h2.mvstore.db.MVTableEngine$1.uncaughtException(MVTableEngine.java:95)
at org.h2.mvstore.MVStore.handleException(MVStore.java:2506)
at org.h2.mvstore.MVStore.panic(MVStore.java:383)
at org.h2.mvstore.MVStore.<init>(MVStore.java:364)
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2934)
at org.h2.mvstore.db.MVTableEngine$Store.open(MVTableEngine.java:155)
at org.h2.mvstore.db.MVTableEngine.init(MVTableEngine.java:100)
at org.h2.engine.Database.getPageStore(Database.java:2538)
at org.h2.engine.Database.open(Database.java:709)
at org.h2.engine.Database.openDatabase(Database.java:286)
at org.h2.engine.Database.<init>(Database.java:280)
at org.h2.engine.Engine.openSession(Engine.java:66)
at org.h2.engine.Engine.openSession(Engine.java:179)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:157)
at org.h2.engine.Engine.createSession(Engine.java:140)
at org.h2.engine.Engine.createSession(Engine.java:28)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:351)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:124)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:103)
at org.h2.Driver.connect(Driver.java:69)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:678)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
at university.at.jku.ce.h2dao.H2StudentDao.getAllStudents(H2StudentDao.java:37)
at university.at.jku.ce.service.StudentServiceImpl.getAllStudents(StudentServiceImpl.java:21)
at university.at.jku.ce.resource.StudentResource.getStudents(StudentResource.java:31)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:76)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:148)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:191)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:200)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:103)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:493)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:415)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:104)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:277)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268)
at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
at org.glassfish.jersey.internal.Errors.process(Errors.java:268)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1152)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: org.h2.jdbc.JdbcSQLException: Allgemeiner Fehler: "java.lang.IllegalStateException: The file is locked: nio:C:/Users/Michael/development/workspace-ce5/at.jku.ce/data/Database.mv.db [1.4.197/7]"
General error: "java.lang.IllegalStateException: The file is locked: nio:C:/Users/Michael/development/workspace-ce5/at.jku.ce/data/Database.mv.db [1.4.197/7]" [50000-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
... 74 more
Caused by: java.lang.IllegalStateException: The file is locked: nio:C:/Users/Michael/development/workspace-ce5/at.jku.ce/data/Database.mv.db [1.4.197/7]
at org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:870)
at org.h2.mvstore.FileStore.open(FileStore.java:173)
at org.h2.mvstore.MVStore.<init>(MVStore.java:350)
... 68 more
2019-01-12 14:46:32 jdbc[3]: exception
org.h2.jdbc.JdbcSQLException: Methode nur zulässig for eine Abfrage. Erlaubt sind execute oder executeUpdate, nicht jedoch executeQuery
Method is only allowed for a query. Use execute or executeUpdate instead of executeQuery; SQL statement:
INSERT INTO student values(?,?,?) [90002-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.command.Prepared.query(Prepared.java:219)
at org.h2.command.CommandContainer.query(CommandContainer.java:114)
at org.h2.command.Command.executeQuery(Command.java:202)
at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:114)
at university.at.jku.ce.h2dao.H2StudentDao.addStudent(H2StudentDao.java:139)
at university.at.jku.ce.service.StudentServiceImpl.addStudent(StudentServiceImpl.java:26)
at university.at.jku.ce.resource.StudentResource.addStudent(StudentResource.java:40)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:76)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:148)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:191)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:243)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:103)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:493)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:415)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:104)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:277)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268)
at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
at org.glassfish.jersey.internal.Errors.process(Errors.java:268)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1152)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:844)
2019-01-12 16:08:21 jdbc[3]: exception
org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL Befehl "INSERT INTO STUDY VALUES(?,? [*]"; erwartet "[, ::, *, /, %, +, -, ||, ~, !~, NOT, LIKE, ILIKE, REGEXP, IS, IN, BETWEEN, AND, OR, ,, )"
Syntax error in SQL statement "INSERT INTO STUDY VALUES(?,? [*]"; expected "[, ::, *, /, %, +, -, ||, ~, !~, NOT, LIKE, ILIKE, REGEXP, IS, IN, BETWEEN, AND, OR, ,, )"; SQL statement:
INSERT INTO study values(?,? [42001-197]
2019-01-12 17:46:37 jdbc[3]: exception
org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL Befehl "UPDATE SUBJECT SET NAME=?, ECTS=? WHERE STUDYID=?,[*] SUBJECTID=? "
Syntax error in SQL statement "UPDATE SUBJECT SET NAME=?, ECTS=? WHERE STUDYID=?,[*] SUBJECTID=? "; SQL statement:
UPDATE subject SET name=?, ects=? WHERE studyid=?, subjectid=? [42000-197]
2019-01-12 17:47:36 jdbc[3]: exception
org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL Befehl "UPDATE SUBJECT SET NAME=?, ECTS=? WHERE STUDYID=?,[*] SUBJECTID=? "
Syntax error in SQL statement "UPDATE SUBJECT SET NAME=?, ECTS=? WHERE STUDYID=?,[*] SUBJECTID=? "; SQL statement:
UPDATE subject SET name=?, ects=? WHERE studyid=?, subjectid=? [42000-197]
2019-01-12 18:25:46 jdbc[3]: exception
org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL Befehl "SELECT S.* FROM INSCRIPTION I INNER STUDY[*] S ON I.STUDYID=S.STUDYID WHERE I.MATRNR=? "; erwartet "JOIN"
Syntax error in SQL statement "SELECT S.* FROM INSCRIPTION I INNER STUDY[*] S ON I.STUDYID=S.STUDYID WHERE I.MATRNR=? "; expected "JOIN"; SQL statement:
SELECT s.* FROM inscription i INNER study s ON i.studyid=s.studyid WHERE i.matrnr=? [42001-197]
......@@ -24,6 +24,8 @@
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
......@@ -75,15 +77,19 @@
<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>
</dependencies>
<properties>
<jersey.version>2.27</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
......@@ -4,8 +4,18 @@ import java.util.List;
import java.util.Map;
import university.at.jku.ce.model.Student;
import university.at.jku.ce.model.Study;
public interface StudentDao {
public Student getStudent(long matrNr);
public Map<Long,Student>getAllStudents();
public Student getStudent(int matrNr);
public List<Student>getAllStudents();
public Student addStudent(Student student);
public Student updateStudent(Student student);
public void removeStudent(int matrNr);
public List<Study> getInscriptions(int matrNr);
}
package university.at.jku.ce.dao;
import java.util.List;
import java.util.Map;
import university.at.jku.ce.model.Study;
public interface StudyDao {
public abstract Map<Long,Study> getAllStudies(String name);
public List<Study> getAllStudies(String name);
public abstract Study getStudy(Long id);
public Study getStudy(int studyId);
public abstract Study addStudy(Study study);
public Study addStudy(Study study);
public abstract Study updateStudy(Study study);
public Study updateStudy(Study study);
public abstract void removeStudy(long studyId);
public void removeStudy(int studyId);
}
package university.at.jku.ce.dao;
import java.util.List;
import java.util.Map;
import university.at.jku.ce.model.Subject;
public interface SubjectDao {
public abstract Map<Long,Subject> getAllSubjects(Long studyId);
public List<Subject> getAllSubjects(int studyId);
public abstract Subject getSubject(long studyId, long id);
public Subject getSubject(int studyId,int subjectId);
public abstract Subject addSubject (long studyId, Subject subject);
public Subject addSubject (Subject subject);
public abstract Subject updateSubject (long studyId, Subject subject);
public Subject updateSubject (Subject subject);
public abstract void removeSubject (long studyId, long id);
public void removeSubject (int studyId, int subjectId);
}
package university.at.jku.ce.dao;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import university.at.jku.ce.model.Student;
import university.at.jku.ce.model.Study;
public class TextStudentDao implements StudentDao {
Map <Long,Student> students;
@Override
public Student getStudent(long matrNr) {
getAllStudents();
return students.get(matrNr);
}
@Override
public Map<Long,Student> getAllStudents() {
ArrayList <String> lineList=new ArrayList<String>();
students=new HashMap<Long,Student>();
try {
FileReader fr = new FileReader("C:\\Users\\Michael\\development\\workspace-ce5\\at.jku.ce\\src\\main\\resources\\Students.txt");
BufferedReader br = new BufferedReader(fr);
String line="";
do{
line = br.readLine();
lineList.add(line);
}
while (line != null);
br.close();
} catch (Throwable t) {t.printStackTrace();}