Search code examples
databasespring-bootintellij-ideafrontendh2

How to create a java code in intelliJ connected to an h2 database?


I got a task in Uni where I have to create a basic website for a car dealership. Basically the website lets me filter between different car models, prices, colours and the year the car was made. My professor told us she would like for us to use H2 to create a database. Though it does not matter if the database is serverbased or embedded. Problem is i have never actually created a database. We just learned about the term "select" within IBM to get to know the basics of SQL.

My professors prefers to throws us into the cold water a lot.

I looked up online how to create a code that is connected to h2. I still don't fully understand h2, although I did find out abou "spring boot". Tutorials use "spring boot initialzr" to write their project but I don't have the necessary ultimate edition of IntelliJ to use that. I dont even know what spring boot is or does.

I am lost in the sea of code. Please help.


Solution

  • "My professors prefers to throws us into the cold water a lot."

    We all are there some point in life, haha. And believe it or not sometimes that the best you to get you started.

    Anyways the project that is assigned to you serves as a good starting point to get your hand dirty in various technology.

    Here are few points which will help you.

    Point 1: Spring boot is web framework which let you build web applications. this is little advance items assuming the scope of your project. What you can do is research about how to create web applications using JSP and go on from there.

    Point 2: The database you are referring here is just a program running in separate process if are talking about h2 database. best selling point of h2 is its optimized for speed and have full fledged features of SQL compliant database.

    Below is very good resources to start your project: (All 3 modes are explained)

    https://www.codejava.net/java-se/jdbc/connect-to-h2-database-examples

    Where in that, they have a section below:

    5. Java Connect to H2 Database in In-Memory Mode

    By the time you have this code executed at line no. 17 of given code snippet. You already have a SQL compliant database at your service.

    Hope this helps and good luck with your project.