如何呼叫H2 LINK_SCHEMA?

问题描述 投票:0回答:1

我正在尝试运行link_schema

    final String query = "? = CALL LINK_SCHEMA('ROADS', '', '" + url + "', '" + user + "', '" + pass + "', 'ROADS');";
    CallableStatement statement = con.prepareCall(query);
    statement.execute();
    ResultSet rs = statement.getResultSet();

我得到一个ResultSet,但它不包含承诺的表列表。同样,稍后当我尝试访问表时,出现错误“找不到架构”。我哪里出错了?

java jdbc h2
1个回答
0
投票

您需要使用

Statement st = con.createStatement();
ResultSet rs = st.executeQuery("CALL LINK_SCHEMA(…)");

或更安全可靠

PreparedStatement ps = con.prepareStatement("CALL LINK_SCHEMA(?, '', ?, ?, ?, ?)");
ps.setString(1, "ROADS");
ps.setString(2, url);
ps.setString(3, user);
ps.setString(4, pass);
ps.setString(5, "ROADS");
ResultSet rs = ps.executeQuery();
© www.soinside.com 2019 - 2024. All rights reserved.