Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8926365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:57:34+00:00 2026-06-15T07:57:34+00:00

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

  • 0

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 function getStat() returns setof stat as 'select distinct table1.type, table1.location, table1.number from table1, table2 where table2.finding=10 order by number desc;' language 'sql';

Now here is the jdbc code:

CallableStatement callable = null;

    String storedProc = "{call getStat(?, ?, ?)}";

    try {
        callable = connection.prepareCall(storedProc);

        callable.registerOutParameter(1, java.sql.Types.VARCHAR);
        callable.registerOutParameter(2, java.sql.Types.VARCHAR);
        callable.registerOutParameter(3, java.sql.Types.INTEGER);

        boolean results = callable.execute();

        System.out.println(callable.getString(1));
        System.out.println(callable.getString(2));
        System.out.println(callable.getInt(3));

        while(results){
            ResultSet rs = callable.getResultSet();
            while(rs.next()){
                System.out.println(rs.getString(1));
                System.out.println(rs.getString(2));
                System.out.println(rs.getInt(3));
            }
            //rs.close();

            results = callable.getMoreResults();
        }

Okay, and now the problem:
When I am calling it, it just prints out the first line, of the whole bulk, that should be printend. Yeah, that is clear, because I execute the following code:

            System.out.println(callable.getString(1));
            System.out.println(callable.getString(2));
            System.out.println(callable.getInt(3));

But I do the same in the while loop…and nothing more is displayed.

Maybe the problem is something obvious, but I am missing that 🙁

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:57:36+00:00Added an answer on June 15, 2026 at 7:57 am

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just tried the tooltip like this Easy image preview ... But i cant
I am writing an assembly function to be called from C that will call
I just tried to run my test app and I got this error: 2012-06-16
I just tried my first steps with grid . I would like to set
I am having difficulty executing a MS SQL Server stored procedure from Java/jsp. I
I'm having a never-ending problem with trying to call a stored procedure from a
I'm having trouble specifically with the getimagesize function. I'm making the function call from
I hate that I'm doing this but I've just started working with Javascript classes
I'm looking to create a Button class in my custom XNA GUI that accepts
I have a utility function that enumerates all values of a type that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.