Reputation: 1687
I beg pardon for not doing homework on this issue and directly asking question but i need to understand what is the meaning of the connection string "jdbc:h2:h2db/database" in order to get h2 Database connection.
I want to know that if I am using above string in my web application (coded on Spring and hibernate framework ) which is hosted on tomcat server then where is my DB located..
Plz if some one can explain me briefly then it will be a GREAT GREAT help. I am a newbie and have to understand many more things so i am posting this question without googling about H2 database
Kindly HELP!!!!
Upvotes: 3
Views: 5815
Reputation: 22481
This String means "connect to h2 in embedded mode, and point it to the db located at [running app path]/h2db/database". If one doesn't exists, create it for me". You can also use a absolute path (starting with "/") such as jdbc:h2:/dbs/h2/database. Search for a h2db folder within your working directory.
Upvotes: 4
Reputation: 7779
The connection string or connection url is exactly that - specifying connection details to the database through a driver. The driver in this case is a JDBC driver, which is Java's way of talking to the database. The database providers implement this interface and provide the drivers. The part before : in your case is the protocol, which is jdbc. Other protocol can be jdbc:odbc for the JDBC-ODBC bridge. After the protocol is db vendor specifier, which in this case is h2, and finally its the database name. There is no specific standard on how a connection string should be structured, but pretty much procotol:database_type:database_name:port are common.
Here are a bunch of connection strings for you to look at.
From your connection string it appears you're using h2 in embedded mode, so the db is sitting on the same box as your tomcat.
Upvotes: 5