在Win64上的H2中创建存储函数

时间:2013-04-16 15:17:43

标签: h2 flyway

在创建用户定义的函数期间,我在Win64环境中遇到错误。我正在使用flyway执行以下简单脚本:

CREATE ALIAS TRANSLATE_NAME AS $$
String TRANSLATE_NAME(String value) {
  ...
return null;
}
$$

我收到以下错误:

java.io.IOException: CreateProcess error=2, The system cannot find the file specified

17:10:38 ERROR (ApacheCommonsLog.java:51) - com.googlecode.flyway.core.api.FlywayException: 
Error executing statement at line 1: 
CREATE ALIAS TRANSLATE_NAME AS $$

String TRANSLATE_NAME(String value) {
return null;
}
$$

这仅出现在Win64上,无论是在32位Linux还是32位Windows上。

有什么想法吗?我会很感激!请!

日志:

17:10:37 INFO (DriverManagerDataSource.java:153) - Loaded JDBC driver: org.h2.Driver
17:10:37 INFO (AbstractApplicationContext.java:1374) - Bean 'dataSource' of type [class org.springframework.jdbc.datasource.DriverManagerDataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
17:10:38 INFO (ApacheCommonsLog.java:43) - Creating Metadata table: "PUBLIC"."schema_version"
17:10:38 INFO (ApacheCommonsLog.java:43) - Current version of schema "PUBLIC": << Empty Schema >>
17:10:38 INFO (ApacheCommonsLog.java:43) - Migrating schema "PUBLIC" to version 1.1
17:10:38 INFO (ApacheCommonsLog.java:43) - Migrating schema "PUBLIC" to version 1.2
17:10:38 INFO (ApacheCommonsLog.java:43) - Migrating schema "PUBLIC" to version 1.3
17:10:38 INFO (ApacheCommonsLog.java:43) - Migrating schema "PUBLIC" to version 1.4
17:10:38 ERROR (ApacheCommonsLog.java:51) - com.googlecode.flyway.core.api.FlywayException: Error executing statement at line 1: CREATE ALIAS TRANSLATE_NAME AS $$
String TRANSLATE_NAME(String value) {
    if (value.equals("Ilya")) {
        return "Юлия";
    }
    return null;
}
$$
17:10:38 ERROR (ApacheCommonsLog.java:51) - Caused by java.io.IOException: CreateProcess error=2, The system cannot find the file specified
17:10:38 INFO (DefaultSingletonBeanRegistry.java:444) - Destroying singletons in...

2 个答案:

答案 0 :(得分:1)

H2需要在类路径中的JDK(类路径中的tools.jar),或者javac需要作为外部进程使用。要查明类javac是否在类路径中,请打开命令提示符并键入javac [Enter]。

答案 1 :(得分:0)

就我而言,JAVA_HOME被定义为一个环境变量,并指向错误的JRE(没有javac命令)。我删除它,因为它不再需要,并且做了伎俩。虽然这不太可能是您的特定情况,但它证明这与解决jdks路径的环境变量有关。