当我创建一个别名用于在 H2 数据库中注册 java 函数时,它给出了找不到类的错误。我在 tcp 连接上运行 h2 数据库。
样本,
public class TimeFrame {
public static void main(String... args) throws Exception {
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:tcp://MYIP:9092/~/test", "sa", "");
Statement stat = conn.createStatement();
//Setup Table
stat.execute("DROP TABLE IF EXISTS timeframe");
stat.execute("CREATE TABLE timeframe (last_updated TIMESTAMP, ip int");
stat.execute("CREATE ALIAS IF NOT EXISTS SLIDEWINDOW FOR \"h2TimeFrame.TimeFrame.slidewindow\" ");
}
}
这一切都在包装名称中:h2TimeFrame。去测试,
从 org.h2.samples 包中获取示例类“Function”。您将如何通过 TCP 连接在服务器上运行此类。改变
Connection conn = DriverManager.getConnection("jdbc:h2:~/test", "sa", "");
至
Connection conn = DriverManager.getConnection("jdbc:h2:tcp://IPADDRESS:9092/~/test", "sa", "");