h2

create alias with the same name but not the same signature

坚强是说给别人听的谎言 提交于 2019-12-12 02:37:46
问题 In order to use H2 database in our Junit tests instead of calling Oracle, I am blocked on creating aliases on H2 to emulate some Oracle compatibility : I first declared an alias for to_char for date to char conversion : works fine create alias TO_CHAR as $$ java.lang.String toChar(java.util.Date date, String format) throws Exception{ ... }$$; Then I try to declare an alias for to_char for number to char conversion : now h2 doesn't accept it : create alias TO_CHAR as $$ java.lang.String toChar

Roo 1.2.0 basic application with datanucleus still buggy

╄→гoц情女王★ 提交于 2019-12-11 22:45:33
问题 A few days ago, I posted Roo 1.1.5 super basic application is buggy, and just recently on Dec 17, 2011, Spring Roo 1.2.0 has been released. I created the equivalent project: project --topLevelPackage task --java 6 --projectName Task jpa setup --provider DATANUCLEUS --database H2_IN_MEMORY entity jpa --class ~.domain.Task field string --fieldName description --notNull --sizeMin 3 --sizeMax 512 field boolean --fieldName completed --notNull web jsf setup controller all --package ~.controller

How can I connect to read only H2 database file which is inside runnable jar?

落爺英雄遲暮 提交于 2019-12-11 21:33:39
问题 I've requirement to create database once with create/insert statements and then make it available inside javafx runnable jar with read only DB access. I just gone through H2 database document many time and tried to achieve this using H2 Driver version 1.4.196 and 1.4.192 but I think I'm missing something. I can connect without including it into runnable jar and read only things works as well. But I need to access it from jar itself to prevent DB access from outsiders. Can I've connection

If using Hibernate with Database (and c3p0 dbpooling) is is still possible and safe to directly get connection bypassing Hibernate

柔情痞子 提交于 2019-12-11 18:45:56
问题 Using Hibernate 4.3.11 with H2 1.4.199 and C3p0 If using Hibernate with Database is is still possible and safe to directly get connection from pool bypassing Hibernate? Im trying to write an sql query, now I know I can use session.createSQLQuery() but this returns a Hibernate org.hibernate SQLQuery class rather than a java.sql.Connection and this is causing a problem for me trying to set the parameters, so I wanted to try using a Connection instead. 回答1: Try this. import org.hibernate.engine

Exception in thread “main” java.lang.ClassNotFoundException: org.h2.Driver

岁酱吖の 提交于 2019-12-11 18:08:29
问题 I am working on a dB viewer for a h2 database in java. I am using a sample code to try and connect to it as follows: import java.sql.*; public class db { public static void main(String[] a) throws Exception { Class.forName("org.h2.Driver"); Connection conn = DriverManager. getConnection("jdbc:h2:~/test", "sa", ""); // add application code here conn.close(); } } But when I run it I get the following error: Exception in thread "main" java.lang.ClassNotFoundException: org.h2.Driver at java.net

how h2 chooses right/wrong index in Join

梦想与她 提交于 2019-12-11 14:47:35
问题 I had an issues with a named query in Java, but the issue was that the problem was in H2. I thought ANALYZE was my Solution and would solve my problem. It did locally on my dev machine. On client side it did made it worse. Scenario: I have an H2 Database with data version 105. After importing some more data it becomes version 106. The Table looks like The Query (get the rows with given guid, local and highest version): SELECT tdo.TECDOC_GUID as guid, tdo.TECDOC_LOCALE as locale , tdo.TECDOC

How to define Oracle Package Procedure in H2 for Testing

我们两清 提交于 2019-12-11 14:06:01
问题 I am testing an spring boot application that reads/writes data to an Oracle DB. This Oracle DB has Oracle packages and in those packages procedures. At some point, the spring boot application calls this procedure via a Entity Repository as follows @Repository public interface StudentRepository extends JpaRepository<Student, String> { @Modifying @Query(value = "begin sch1.STUDENT_PACKAGE.Set_Grades_To_A('A'); end;", nativeQuery = true) public void setStudentGradeToA(); } So, it uses a native

How to insert a specific UUID in h2 database?

我的未来我决定 提交于 2019-12-11 13:21:34
问题 I need to insert some default data in my database. I am using Spring Boot with the Flyway integration. For testing, I use H2. For production MySQL will be used. I have made separate Flyway migration scripts so I can use database specific stuff for the default data (Creating the tables is done in a common script). For MySQL, I have something like this: INSERT INTO survey_definition (id, name, period) VALUES (0x2D1EBC5B7D2741979CF0E84451C5BBB1, 'disease-activity', 'P1M'); How can I do the same

Set IGNORECASE and other options for H2 in a Play! Framework test

主宰稳场 提交于 2019-12-11 12:38:27
问题 I've setup my Play! (with Slick) application to use H2 when running tests, and it has worked great so far. I'm getting an error now, because of a plain-SQL query that uses lower-case column and table names, and H2 complains that the TABLE (all uppercase) could not be found. Now I need to set a few options, IGNORECASE for sure, and possibly the MODE . When I setup my database for tests, I use def fakeAppWithMemoryDatabase = FakeApplication(additionalConfiguration = inMemoryDatabase()) For

Cannot use setArray JDBC (integer) with H2 Database

大兔子大兔子 提交于 2019-12-11 12:27:59
问题 I want to put an array of integers in my jdbc query with H2 database. Integer[] list = new Integer[]{1,2,3}; String query = "SELECT EXAMPLE FROM DATA WHERE EXAMPLE IN (?)"; PreparedStatement ps = GestionBDD.getConexionBD().prepareStatement(query); Array array = GestionBDD.getConexionBD().createArrayOf("int", list); ps.setArray(1, array); ResultSet rs = ps.executeQuery(); while (rs.next()) { // DO THINGS } But doest not work, I am getting this exception : org.h2.jdbc.JdbcSQLException: Data