我正在尝试运行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
,但它不包含承诺的表列表。同样,稍后当我尝试访问表时,出现错误“找不到架构”。我哪里出错了?
您需要使用
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();