Hello,
Thank you for responding
Here is the code that works when executed against 4.1.186
packageorg.zrgs.h2;*
*importorg.junit.Test;
importorg.slf4j.Logger;
importorg.slf4j.LoggerFactory;
import java.lang.invoke.MethodHandles;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
* @author glick
*/
public class JdbcTimestampEscapeSyntaxTest
{
private static final transient Logger LOG =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@Test
public void testTSJbcEscapeSyntax() throws SQLException
{
String connectString =
"jdbc:h2:tcp://127.0.0.1/mem:top;MODE=Oracle;MVCC=TRUE;DEFAULT_LOCK_TIMEOUT=60000;DB_CLOSE_ON_EXIT=FALSE;";
Connection connection = DriverManager.getConnection(connectString, "top",
"top");
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("select TIMESTAMP '2015-03-16
12:12:12.12' ");
while (resultSet.next())
{
LOG.info(resultSet.getTimestamp(1).toString());
}
}
}
If I replace
ResultSet resultSet = statement.executeQuery("select TIMESTAMP '2015-03-16
12:12:12.12' ");
with this
ResultSet resultSet = statement.executeQuery("select { TS '2015-03-16 12:12:12.12'
}");
I get this stack trace:
/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/bin/java -ea
-Didea.launcher.port=7532 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA
15.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA
15.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA
15.app/Contents/plugins/junit/lib/junit-rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/htmlconverter.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Users/c1alg01/java/h2-work/h2-work/target/test-classes:/Users/c1alg01/java/h2-work/h2-work/target/classes:/Users/c1alg01/.m2/repository/org/springframework/spring-jdbc/4.1.3.RELEASE/spring-jdbc-4.1.3.RELEASE.jar:/Users/c1alg01/.m2/repository/org/springframework/spring-beans/4.1.3.RELEASE/spring-beans-4.1.3.RELEASE.jar:/Users/c1alg01/.m2/repository/org/springframework/spring-core/4.1.3.RELEASE/spring-core-4.1.3.RELEASE.jar:/Users/c1alg01/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/Users/c1alg01/.m2/repository/org/springframework/spring-tx/4.1.3.RELEASE/spring-tx-4.1.3.RELEASE.jar:/Users/c1alg01/.m2/repository/org/jboss/jboss-vfs/3.2.8.Final/jboss-vfs-3.2.8.Final.jar:/Users/c1alg01/.m2/repository/org/jboss/logging/jboss-logging/3.1.4.GA/jboss-logging-3.1.4.GA.jar:/Users/c1alg01/.m2/repository/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar:/Users/c1alg01/.m2/repository/com/h2database/h2/1.4.184/h2-1.4.184.jar:/Users/c1alg01/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.9/jcl-over-slf4j-1.7.9.jar:/Users/c1alg01/.m2/repository/org/slf4j/jul-to-slf4j/1.7.9/jul-to-slf4j-1.7.9.jar:/Users/c1alg01/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.9/log4j-over-slf4j-1.7.9.jar:/Users/c1alg01/.m2/repository/org/slf4j/slf4j-api/1.7.9/slf4j-api-1.7.9.jar:/Users/c1alg01/.m2/repository/junit/junit/4.12/junit-4.12.jar:/Users/c1alg01/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"
com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter
-ideVersion5 org.zrgs.h2.JdbcTimestampEscapeSyntaxTest
org.h2.jdbc.JdbcSQLException: Column "TS" not found; SQL statement:
select TS '2015-03-16 12:12:12.12' [42122-170]
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.expression.ExpressionColumn.optimize(ExpressionColumn.java:141)
at org.h2.command.dml.Select.prepare(Select.java:799)
at org.h2.command.Parser.prepareCommand(Parser.java:218)
at org.h2.engine.Session.prepareLocal(Session.java:414)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:253)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
at java.lang.Thread.run(Thread.java:745)
at org.h2.engine.SessionRemote.done(SessionRemote.java:622)
at org.h2.command.CommandRemote.prepare(CommandRemote.java:68)
at org.h2.command.CommandRemote.<init>(CommandRemote.java:45)
at org.h2.engine.SessionRemote.prepareCommand(SessionRemote.java:492)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1189)
at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:73)
at
org.zrgs.h2.JdbcTimestampEscapeSyntaxTest.testTSJbcEscapeSyntax(JdbcTimestampEscapeSyntaxTest.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
details.
Process finished with exit code 255
On 3/17/15 11:29 AM, Fred&Dani&Pandora&Aquiles wrote:
Hi,
The following tests are working for me in latest version:
select TS '2090-01-01 00:00:00.0';
select TIMESTAMP '2090-01-01 00:00:00.0';
Can you post the complete stack trace?
Regards,
Fred
2015-03-13 15:44 GMT-03:00 Andy Glick <[email protected]
<mailto:[email protected]>>:
We are using Eclipselink 2.6.0.RC1 with H2 1.4.180 and most of the
SQL for a large application is being generated by Eclipselink and
is working fine.
Starting with versions greater than 1.4.180 and I not exactly sure
which, the SQL that Eclipselink is generating is being rejected by
H2 as invalid SQL. Looking at the SQL that is failing indicates
that Eclipselink is generating requests to convert a String to a
Timestamp as follows:
TS '2090-01-01 00:00:00.0'
when I am using H2 version 1.4.186 queries using TS as the name of
the Timestamp conversion function fail, but for the same query if
the name of the Timestamp conversion function is changed to
TIMESTAMP then the query executes successfully.
From everything I can determine this change is intentional and a
breaking change. Releases from somewhere around1.4.180 and before
do not support TIMESTAMP as the name of the String to Timestamp
conversion function and releases somewhere after 1.4.180 do not
support TS as the name of the String to Timestamp conversion function.
So this looks like a breaking change, but your documentation
hasn't announced that such a change has been made to the code base.
1) Have you changed the behavior of the code and introduced a
non-backward compatible breaking change?
2) If the behavior has changed when will you document the behavior?
--
You received this message because you are subscribed to the Google
Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.