我正在尝试在内存数据库中创建一个 Derby 进行测试,以镜像我们使用的 Oracle 数据库。我试图执行我们使用的第一个脚本来设置 Oracle 数据库,但我得到了一个 SQLSyntaxException。
马文:
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.10.1.1</version>
</dependency>
代码:
private static String sqlStatement ="set echo on\n" +
"set feedback on\n" +
"set serveroutput on\n" +
"var start_date varchar2(80);\n" +
"var start_date varchar2(80);\n" +
"var end_date varchar2(80);\n" +
"var sid varchar2(10);\n" +
"var host varchar2(30);\n" +
"var user varchar2(30);\n" +
"spool DS_Create_Schema.log;\n" +
"\n" +
"begin\n" +
" select to_char(sysdate, 'mm-dd-yyyy hh24:mi:ss') into :start_date from dual;\n"
...
final String sql = sqlStatement;
final String connURL = "jdbc:derby:memory:memdatabase;create=true";
Connection conn = null;
try {
conn = DriverManager.getConnection(connURL);
PreparedStatement ps = conn.prepareStatement(sql);
boolean success = ps.execute();
System.out.println("Memory database created: " + success);
} catch (SQLException e) {...