h2dbを使ってデータを挿入したいがうまくできなくて困っています。どのようにしたら、データを挿入できるか教えていただけませんか。
application.properties
server.port=8086
1spring.datasource.driver-class-name=org.h2.Driver 2spring.datasource.url=jdbc:h2:./h2db/sampledb 3spring.datasource.username=sa 4spring.datasource.password= 5 6 7 8 9コード
src/main/resources
data.sql
```INSERT INTO date (no,word,year,month,day) VALUES(1、"明日",0,0,1); コード
schema.sql
create table if not exists date(no int,word varchar primary key,year int,month int,day );
エラー文
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2020-05-18 12:59:48.216 ERROR 15700 --- [ restartedMain] o.sCaused by: org.springframework.beans.factory.BeanCreationException: Error org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcatcreating bean with name 'h2Console' defined in class path resource [org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.ServletRegistrationBean]: Factory method 'h2Console' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Users/unonaoki/git/test/raise/target/classes/data.sql]: INSERT INTO date (no,word,year,month,day) VALUES(1、"明日",0,0,1); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: SQLステートメントに文法エラーがあります "INSERT INTO DATE (NO,WORD,YEAR,MONTH,DAY) VALUES(1[*]、""明日"",0,0,1)" Syntax error in SQL statement "INSERT INTO DATE (NO,WORD,YEAR,MONTH,DAY) VALUES(1[*]、""明日"",0,0,1)"; SQL statement: INSERT INTO date (no,word,year,month,day) VALUES(1、"明日",0,0,1) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Users/unonaoki/git/test/raise/target/classes/data.sql]: INSERT INTO date (no,word,year,month,day) VALUES(1、"明日",0,0,1); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: SQLステートメントに文法エラーがあります "INSERT INTO DATE (NO,WORD,YEAR,MONTH,DAY) VALUES(1[*]、""明日"",0,0,1)" Syntax error in SQL statement "INSERT INTO DATE (NO,WORD,YEAR,MONTH,DAY) VALUES(1[*]、""明日"",0,0,1)"; SQL statement: INSERT INTO date (no,word,year,month,day) VALUES(1、"明日",0,0,1) [42000-200] [42000-200] コード
回答1件
あなたの回答
tips
プレビュー