Hello,
I have stored procedure the same as the one below:
The code I am using in my java program is listed below:Code:DELIMITER $$ DROP PROCEDURE IF EXISTS `flightdb`.`spGetAirportCodes`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `spGetAirportCodes`() BEGIN SELECT AirportCode FROM Airports; END$$ DELIMITER ;
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.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() ); }
Is the java code for calling a stored procedure and return a resultset correct?
Many thanks in advance,
Steve




Reply With Quote