Tag: h2db

无法从H2 db获得结果

我试图从h2 db获取值,但总是得到这个错误 org.h2.jdbc.JdbcSQLException: No data is available [2000-171] at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) at org.h2.message.DbException.get(DbException.java:169) at org.h2.message.DbException.get(DbException.java:146) at org.h2.message.DbException.get(DbException.java:135) at org.h2.jdbc.JdbcResultSet.checkOnValidRow(JdbcResultSet.java:2956) at org.h2.jdbc.JdbcResultSet.get(JdbcResultSet.java:2962) at org.h2.jdbc.JdbcResultSet.getInt(JdbcResultSet.java:306) 我google了一个答案 一定要调用rs.next(); 在使用任何getter方法之前。 但我打电话给rs.next()……就是无法理解 这是我的代码: public User getUser(int userId) throws SQLException { User u = new User(userId); try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(“SELECT * FROM invited_users WHERE user_id=” + […]

如何显示本地h2数据库(Web控制台)的内容?

最近我加入了一个新的团队,这里的人们使用h2进行存根服务。 我想知道我是否可以使用Web界面显示此数据库的内容。 在工作中,可以访问localhost:5080 我有一个项目,我使用h2数据库,但当我点击localhost:5080时,我看不到h2 web控制台 我也试过localhost:8082 – 它也不起作用。 我的项目配置(成功运行): classpath:hibernate-test.cfg.xml false UTF-8 true create-drop 我没有想法如何访问h2 web控制台。 请帮忙。 PS 我只在.m2文件夹中看到了h2的提及 PS2 我注意到http://localhost:8082/可以使用web控制台,如果在配置中替换url: 但是如果我已经启动了h2(在.m2文件夹中找到h2 jar文件并点击双击)它就可以了 如果我在启动应用程序时未启动h2 – 我看到以下错误: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:94) … Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dbInitializer’: Invocation of init method failed; nested exception is org.hibernate.exception.GenericJDBCException: Could not open […]