postgresql with jdbc and stored procedures (functions): ResultSet

前端 未结 1 1419
慢半拍i
慢半拍i 2021-02-11 03:56

I just tried to call a stored function from the server (getStat), that is looking like this:

create type stat as (type text, location text, number int);
create f         


        
1条回答
  •  星月不相逢
    2021-02-11 04:20

    No need to use a CallableStatement with the {call ...} syntax.

    Just use a select and a regular Statement:

    Statement stmt = connection.createStatement();
    ResultSet rs = stmt.executeQuery("select * from getStat()");
    while (rs.next())
    {
      System.out.println(rs.getString(1));
      System.out.println(rs.getString(2));
      System.out.println(rs.getInt(3));
    }
    

    0 讨论(0)
提交回复
热议问题