h2

How to add the mode=mysql to embedded H2 DB in Spring Boot 1.4.1 for @DataJpaTest?

…衆ロ難τιáo~ 提交于 2019-11-28 02:43:01
问题 I have some problems with using a schema.sql file to create my sql schema when executing a junit test while this schema contains mysql specific expression. I have to add the mode=mysql to the H2 url. For example something like this: jdbc:h2:mem:testd;MODE=MYSQL But Spring boot automatically uses the url defined in the enum org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection with its url jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE . I have tried similiar

H2 database: NULL not allowed for column “ID” when inserting record using jdbcTemplate

谁都会走 提交于 2019-11-28 02:37:33
问题 I use hibernate's hbm2ddl to generate schema automatically. Here is my domain: @Entity public class Reader { @Id @GeneratedValue(strategy=GenerationType.AUTO) Long id; @Column(nullable=false,unique=true) String name; @Enumerated(EnumType.STRING) Gender gender; int age; Date registeredDate = new Date(); // getter and setter ... } When I using hibernate to save a reader , it works fine as expected as it generats a id to the reader . However when I use jdbcTemplate to insert a record with pure

Spring Security: configure(AuthenticationManagerBuilder auth)

寵の児 提交于 2019-11-28 01:39:50
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("...") and .authoritiesByUsernameQuery("..."); be formulated? Error message: Caused by: org.h2.jdbc

Database not found, and IFEXISTS=true, so we cant auto-create it

社会主义新天地 提交于 2019-11-27 23:48:12
问题 I am getting error after opening the h2 database console. I enter database name but it is showing database not found error: Database "C:/Users/Barlekar/onlineshoppings" not found, and IFEXISTS=true, so we cant auto-create it [90146-199] 90146/90146 (Help) org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database "C:/Users/Barlekar/onlineshoppings" not found, and IFEXISTS=true, so we cant auto-create it [90146-199] 回答1: If you are dealing with the Spring Boot project, please change the JDBC

File based h2 persisted but not loaded in Spring Boot

早过忘川 提交于 2019-11-27 23:24:27
问题 I made a small application based on Spring Boot: spring-boot-starter-web spring-boot-starter-data-jpa The application has simply one domain class Post.java . Accordingly there is a RestController and a DAO. The data is supposed to be persisted in a file based hsql db. When the application is running everything seems fine. Data is stored. The h2 file is created and contains insert statements. However, when I kill the application and start it a second time. No data is loaded. (As if a brand new

SQL query that gives distinct results that match multiple columns

僤鯓⒐⒋嵵緔 提交于 2019-11-27 22:33:43
问题 Sorry, I couldn't provide a better title for my problem as I am quite new to SQL. I am looking for a SQL query string that solves the below problem. Let's assume the following table: DOCUMENT_ID | TAG ---------------------------- 1 | tag1 1 | tag2 1 | tag3 2 | tag2 3 | tag1 3 | tag2 4 | tag1 5 | tag3 Now I want to select all distinct document id's that contain one or more tags (but those must provide all specified tags). For example: Select all document_id's with tag1 and tag2 would return 1

Set default timezone H2 database

流过昼夜 提交于 2019-11-27 22:20:14
问题 How can I explicitly set the time zone H2 should use? Now it gets the timezone to use from the underlying OS. I would assume there existed an extra parameter I would add to the connection string ala the one I have below. db.url=jdbc:h2:mem:mybipper;MVCC=true;<timezone=UTC> 回答1: Apparently you don't have a parameter on the connection but the database will use the timezone of the JVM where the driver is loaded so you can set -Duser.timezone=UTC . Note that you can't change the timezone after

H2 database in memory mode cannot be accessed by Console

耗尽温柔 提交于 2019-11-27 19:11:17
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 { RunScript.execute(conn, new InputStreamReader(in)); Statement stat = conn.createStatement();

Jenkins发送测试报告邮件

只愿长相守 提交于 2019-11-27 17:54:58
简介:总结怎么使用Jenkins执行自动化测试后发送测试报告邮件 一、系统设置 1、在Jenkins安装Email Extension Plugin插件,如下图: 2、设置Extended E-mail Notification (1)进入“系统管理”-“系统设置”,对Extended E-mail Notification进行配置,主要点开“高级”才能设置smtp,具体参考下图: 注意:上图中的Password不是qq密码,而是在QQ邮箱申请开通IMAP/SMTP服务后收到的密码。开通IMAP/SMTP服务可参考我的另一篇博客:http://blog.csdn.net/galen2016/article/details/73350606 (2)还是在“系统管理”-“系统设置”页面,系统管理员地址要设置成和发送邮件的地址一致,不然发送邮件会失败 3、设置邮件通知 还是在系统管理-系统设置里面设置,内容和Extended E-mail Notification差不多,具体如下图: 4、Jenkins任务的配置 a、在进入任务的配置页面,然后在构建后操作模块增加构建后的操作“Editable Email Notification”,如图: b、我的Editable Email Notification配置如下: c、注意:还要在高级里设置邮件的触发条件,如下: d、配置格式参考:

View content of H2 or HSQLDB in-memory database

家住魔仙堡 提交于 2019-11-27 17:00:58
Is there a way to browse the content of an H2 or an HSQLDB in-memory database for viewing? For example, during a debugging session with Hibernate in order to check when the flush is executed; or to make sure the script that instantiates the DB gives the expected result. Does it exist an addon or a library that you can embed with your code in order to allow this? Please, mention which one you're talking about (H2 or HSQLDB) in case you have an answer specific to one of them. Tomasz Nurkiewicz You can run H2 web server within your application that will access the same in-memory database. You can