Results 1 to 8 of 8

Thread: store procedure to return a result set [* Resolved *]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Resolved store procedure to return a result set [* Resolved *]

    Hello,

    I have stored procedure the same as the one below:
    Code:
    DELIMITER $$
    
    DROP PROCEDURE IF EXISTS `flightdb`.`spGetAirportCodes`$$
    
    CREATE DEFINER=`root`@`localhost` PROCEDURE `spGetAirportCodes`()
    BEGIN
    	SELECT AirportCode FROM Airports;
    END$$
    
    DELIMITER ;
    The code I am using in my java program is listed below:

    Code:
    ResultSet airportCodes = null;
    	   		
    	   		try
    	   		{
    	   			PreparedStatement ps = conn.prepareStatement( "call spGetAirportCodes" );
    	   			
    	   			airportCodes = ps.executeQuery();		
    	   			
    	   			if ( airportCodes.next() )
    	   			{
    	   				System.out.println("Airport codes have been returned, Well done!" );
    	   			}
    	   		}
    	   		catch( SQLException sqle )
    	   		{
    	   			System.err.println( "\nSQLException: \n" );
    	   			System.err.println( "SQL State: " + sqle.getSQLState() );
    	   			System.err.println( "Message: " + sqle.getMessage() );
    	   		}
    I think the store procedure is correct, I think my code is not working in the java program. I have tried using callable object, but when l run, I get a messsage saying that callable objects are not supported.

    Is the java code for calling a stored procedure and return a resultset correct?

    Many thanks in advance,

    Steve
    Last edited by steve_rm; Sep 12th, 2006 at 05:04 AM.
    steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width