简体   繁体   中英

Unable to insert rows into H2 database from Hibernate project

I am creating a Hibernate project in IntelliJ IDE and trying to hook it up with a H2 database. I created the project based upon this tutorial:

http://www.roseindia.net/hibernate/hibernate4.2/hibernate-example-step-by-step-in-eclipse.shtml

The only change I'm making is the database, instead of MySQL, I'm using H2. However, when I'm trying to run the application, the insertion to the database is shown to have been successful, but there are no signs of any such rows when I open up the database in the H2 console. I've tried many solutions suggested here and elsewhere, including this , this and this . I've tried changing the connection URL of the database in the hibernate.cfg.xml file from a relative path to absolute path, but to no avail. I'm attaching a screenshot of my hibernate.cfg.xml and the relevant portion of the log below. Please help me out with this.

在此处输入图片说明

您的hibernate.connection.url应该类似于jdbc:h2:tcp://localhost/mem:playground我假设您正在从项目中启动H2数据库,因为您是通过控制台连接到H2的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM