I’m trying to run two different SQL scripts when my Java application starts. One for creating the schemas and one for inputting test data. I’d like to keep them separated so I don’t have the edit both files if I have to change something about the schemas in the future.
This is the part from my application-dev.properties where I try to run both scripts:
spring.datasource.url=jdbc:h2:mem:devdb;INIT=RUNSCRIPT FROM 'src/main/resources/SQL_script.sql';RUNSCRIPT FROM 'src/main/resources/H2_data.sql'
This is the error I’m getting from the console in IntelliJ
org.h2.jdbc.JdbcSQLNonTransientConnectionException: URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:devdb" [90046-224]
When I try to only execute one statement, to create the schemas for example, there are no issues.
I’m still fairly new at programming and therefore I’m not sure how to troubleshoot the issue. I’ve tried asking ChatGPT which just kept telling me to check for typos.
I am expecting the SQL_script.sql to run first and create the schemas, afterwards the H2_data script should run and insert test data into my dev database.
Ninjakarlsej is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1