[英]H2 database console error
您好,我是in-memory DB H2
首次用户。 我使用以下配置从应用程序连接。我运行了应用程序,并且看到日志更改。
但是当我尝试查看H2Console
更改并尝试进行连接时,它将如下所示。它无法连接。但是当我终止java应用程序并尝试进行连接时,它将进行连接但没有错误,但是我看不到更改已完成(新在应用程序运行期间插入的行)
当应用程序仍在运行时,如何查看H2
控制台中的更改?
的hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.connection.driver">org.h2.Driver</property>
<property name="hibernate.connection.user">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.url">jdbc:h2:~/h2schema/test</property>
<property name="hibernate.hbm2ddl.auto">update</property>
</session-factory>
</hibernate-configuration>
App.java
{
System.out.println( "Hello World!" );
Alien alien = new Alien("mk", "white", 26l);
Alien alien2 = new Alien("mk1", "white1", 26l);
Configuration configuration = new Configuration().configure().addAnnotatedClass(
Alien.class);
SessionFactory factory = configuration.buildSessionFactory();
Session session = factory.openSession();
Transaction transaction = session.getTransaction();
transaction.begin();
session.save(alien);
session.save(alien2);
System.out.println("-----------");
System.out.println("created user is "+alien);
System.out.println("created user is "+alien2);
System.out.println("-----------");
transaction.commit();
session.close();
}
如此处所述:
H2数据库错误:数据库可能已在使用中:“已被另一个进程锁定”
H2已锁定,请尝试使用TCP在服务器模式下运行
jdbc:h2:tcp://localhost/~/h2schema/test
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.