Hi I am using an H2 database for a tutorial I am following online.
I downloaded the H2 database jar file and put it in a lib file like so:

I also created a library in my project structure like so:

Main code to test:
public class Main {
public static void main(String[] args) throws SQLException {
// write your code here
Server.main();
System.out.println("DB Launched");
}
}
Then I created a db folder - and when I ran my application I entered the path to the DB folder in my project solution for the 'JDBC url'. I followed all of the instructions for the course.
Then when I connected I got the following error (in the web application):

Cannot invoke "java.sql.Connection.getMetaData()" because "<parameter2>" is null
java.lang.NullPointerException: Cannot invoke "java.sql.Connection.getMetaData()" because "<parameter2>" is null
at org.h2.bnf.context.DbContents.readContents(DbContents.java:154)
at org.h2.server.web.WebApp.tables(WebApp.java:698)
at org.h2.server.web.WebApp.process(WebApp.java:225)
at org.h2.server.web.WebApp.processRequest(WebApp.java:170)
at org.h2.server.web.WebThread.process(WebThread.java:134)
at org.h2.server.web.WebThread.run(WebThread.java:90)
at java.base/java.lang.Thread.run(Thread.java:832)
I followed all instructions... I do not know why I am getting this error - I don't know what I'm doing wrong.
Thank you,
tomkt,
Because in the class they ask you to paste in the file name to the JDBC file on the H2 console, but he doesn't show that you need to leave the front items...
So it should be jdbc:h2:C:\your file path
If you are missing the jdbc:h2 at the front of the field it fails with the message you have above enter image description here
Do not delete the "jdbc:h2:" at the beginning. I was following the same course and found my problem. Just replace the ~/test part. So it should look something like "jdbc:h2:D:/..."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With