h2

H2 database error: Database may be already in use: “Locked by another process”

耗尽温柔 提交于 2019-12-17 21:57:41
问题 I am trying to use the H2 database from a Java application. I created the database and its tables through the H2 Console and then I try to connect from Java using Connection con = DriverManager.getConnection("jdbc:h2:~/dbname", "username", "password"); However I receive the following error: Exception in thread "main" org.h2.jdbc.JdbcSQLException: Database may be already in use: "Locked by another process". Possible solutions: close all other connection(s); use the server mode [90020-161] I

JDBC-ResultSet is closed in while-Loop

旧街凉风 提交于 2019-12-17 21:22:57
问题 I'm having a really bad time with a ResultSet, which is closed within a while-Loop for iterating this ResultSet. I have know the exact line in which the ResultSet is closed, but i have no idea why. public LinkedList<Athlet> alleAbrufen () throws SQLException { LinkedList<Athlet> alleAthleten = new LinkedList<Athlet>(); String abrufenAthleten = "SELECT * FROM Athlet ORDER BY athlet_id"; ResultSet athleten_rs = stmt.executeQuery(abrufenAthleten); while (athleten_rs.next()) { long id = athleten

Spring Security: configure(AuthenticationManagerBuilder auth)

烂漫一生 提交于 2019-12-17 16:52:53
问题 I have an entity User with attributes: id username password firstname lastname userrole Attribute userrole is type of enum and no Set , so 1 userrole/user. Now I want to do a JDBC authentication. For now I have: auth .jdbcAuthentication() .dataSource(dataSource) .usersByUsernameQuery("select username, password from user where username=?") .authoritiesByUsernameQuery("select username, userrole from user where username=?"); But this doesn't work. How should the query in .usersByUsernameQuery(".

H2 database in memory mode cannot be accessed by Console

柔情痞子 提交于 2019-12-17 15:38:34
问题 I am creating an in memory database in H2 database by the following code on servlet context startup void initDb() { try { webserver = Server.createWebServer().start(); Class.forName("org.h2.Driver"); Connection conn = DriverManager.getConnection("jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1","SA",""); InputStream in = getClass().getResourceAsStream("script.sql"); if (in == null) { System.out.println("Please add the file script.sql to the classpath, package " + getClass().getPackage().getName()); } else

H2 database column name “GROUP” is a reserved word

坚强是说给别人听的谎言 提交于 2019-12-17 09:59:52
问题 How do I create a table in H2 with a column named GROUP? I saw an example that used something like [*] a while ago, but I can't seem to find it. 回答1: Trailing Underscore Add a trailing underscore : GROUP_ The SQL spec explicitly promises † that no keyword will ever have a trailing underscore. So you are guaranteed that any naming you create with a leading or trailing underscore will never collide with a keyword or reserved word. I name all my columns, constraints, etc. in the database with a

Populate JFreechart TimeSeriesCollection from Mysql DB?

此生再无相见时 提交于 2019-12-17 06:54:43
问题 I'm trying to make a chart in my application that returns me the temperature of days during the months. This chart is a JFreechart TimeSeriesCollection, and I am unable to have the graph read correct data from the database. It shows some of the values, but not all of them, and does not show the correct time. To fix this, I tried to implement the graph as posted here, but still could not solve my problem, even having gone to see this question, as people suggested public class NewClass extends

Frontend tool to manage H2 database [closed]

放肆的年华 提交于 2019-12-17 05:41:01
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . How to use H2 database's integrated managment frontend? For operations such as create table, alter table, add column, and so on. 回答1: I like SQuirreL SQL Client, and NetBeans is very useful; but more often, I just fire up the built-in org.h2.tools.Server and browse port 8082: $ java -cp /opt/h2/bin/h2.jar org.h2

Java学习、面试、求职、干货资源精品合集

强颜欢笑 提交于 2019-12-15 23:35:08
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 本系列文章整合了本号发表和转载过的,有关Java学习、进阶、面试、做项目、求职经验等方面的文章,希望对想要找工作,以及正在找工作的你,能够有所帮助。 原创Java学习专题文章: 如何才能够系统地学习Java并发技术? Java集合类常见面试知识点总结 设计模式常见面试知识点总结 这些喜闻乐见的Java面试知识点,你都掌握了吗? Java工程师学习指南(入门篇) Java工程师学习指南(初级篇) Java工程师学习指南(中级篇) Java工程师学习指南(完结篇) 想了解Java后端学习路线?你只需要这一张图! Java秋招面经大合集 你不可错过的Java学习资源清单 Java工程师修炼之路(校招总结) Java工程师必备书单 精选Java学习专题文章: 从面试官甄别项目经验的角度,说说如何在简历中写项目经验(Java后端方向) 一篇文章让你写出高质量 Java 代码 Java 未来行情到底如何,来看看从业者、培训机构、求职平台都是怎么说的 作为一名Java工程师,你应该了解的Linux知识 国内外知名的 Java 学习网站有哪些? 那些年,我们见过的 Java 服务端乱象 Java开发者薪资最低?程序员只能干到30岁?国外真的没有996?Intellij真的比Eclipse受欢迎? 不用找了,Java

程序人生、生活感悟、职场心得系列文章合集

拈花ヽ惹草 提交于 2019-12-15 23:26:03
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 本系列文章整合了本号发表和转载过的,有关程序员生活、职场、行业前景、人生感悟等方面的精品文章,希望对你的学习、工作以及个人成长有所帮助。 职场心得: 为什么我会选择走 Java 这条路? Java 学到什么程度可以找到第一份工作 ? 那些有实力进入 BAT 的本科生,都做对了什么事? 从三流小公司到一线大厂,聊聊程序员的成长之道 996 盛行的年代,互联网人如何平衡工作和生活 ? 程序人生: 自学编程的朋友,我想给你们这 5 个建议 宁可多花1000元租房,也绝不要去挤半小时地铁 你为什么会做程序员? 拿什么拯救你,我的发际线 程序员江湖一周年,聊聊这一年的所得,所思,所感 我很喜欢玩游戏,那么我就适合做游戏程序员吗? 近期精品 非科班程序员和科班程序员的差距到底在哪里? 细数研究生和导师的那些恩怨情仇 趁着年轻,就应该多去看看这个世界 年轻人应该要明白,职场里不只有晋升 你可能不相信,我每天只写两小时代码 在大公司做凤尾,还是在小公司做鸡头? 如何在互联网上虚度人生? 在阿里工作的日子里,我都学到了哪些东西? 从校园踏入职场之前,你最好先知道这五条建议 那些拼命加班的程序员们,后来都怎么样了? 互联网浪潮之下,聊聊 90 后所面临的困境 程序员的工资到底花到哪里去了? 互联网公司里都有哪些潜规则?

Optimize H2 query: SELECT COUNT(*) FROM table WHERE x=y

那年仲夏 提交于 2019-12-14 04:06:24
问题 I have a query that looks like this: EXPLAIN ANALYZE select count(*) from Table t where t.outcome='SUCCESS' The 'outcome' column has an index. H2 tells me thats its using the index, but I still get something close to a full table scan, because most rows have 'SUCCESS' set, and cardinality is very low. Is there a way to speed this up? Btw., queries without the 'WHERE' part are very fast, just as the doc says. 回答1: What should work is using 3 subqueries: select (select count(*) from table) -