Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    1

    Unanswered: Error in Stored Procedure, Error is: No ResultSet was produced in

    Hi All
    I have written code in Java ie CLASS file.But my DBase is SQL.
    I call a Stored Procedure from my Java Class File.But i get this exception

    java.sql.SQLException: No ResultSet was produced
    at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeQue ry(JdbcOdbcPrepared
    Statement.java:97)
    at AutomaticTicketCursor.CursorATG(AutomaticTicketCur sor.java:254)
    at AutomaticTicketCursor.main(AutomaticTicketCursor.j ava:270)
    Main Fn()

    The Code is written below.

    CREATE PROCEDURE [DBO].[AutoTicketSProcedure]
    @newTicket varchar(15)

    AS
    DECLARE @CMsgID varchar(5),@CStartDateTime smalldatetime,
    @CUpTime varchar(15),@CSeverity varchar(15),@CHostName varchar(25),@CMessage varchar(50)

    DECLARE EventImportCursor CURSOR
    For Select MsgID,StartDateTime,Severity,HostName,Message from EventImport
    where ImportFlag=0 and (Severity like 'Alert' or Severity like 'Debug')

    OPEN EventImportCursor

    FETCH NEXT FROM EventImportCursor Into @CMsgID,@CStartDateTime,@CSeverity,@CHostName,@CMe ssage
    WHILE @@FETCH_STATUS = 0
    BEGIN
    INSERT INTO TICKETINFO (TTNO,Reported_By,Reporting_Time,Nature_of_Fault,M essageID,Severity,TicketType)
    VALUES (@newTicket,@CHostName,@CStartDateTime,@CMessage,@ CMsgID,@CSeverity,'Automatic')

    FETCH NEXT FROM EventImportCursor Into @CMsgID,@CStartDateTime,@CSeverity,@CHostName,@CMe ssage

    END
    CLOSE EventImportCursor
    DEALLOCATE EventImportCursor
    GO


    But when i try to call my Java file

    public void dbConnectATG() throws SQLException{
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    conATG=DriverManager.getConnection("jdbcdbcQL1","","");
    }catch(SQLException e) {
    System.out.println(e);
    }catch(ClassNotFoundException ex){
    ex.printStackTrace();
    }
    }

    public void CursorATG(){
    CallableStatement cs = null;
    String newTicketTest = "2005120201";//null;
    //ResultSet rstATG = null;

    try{
    dbConnectATG() ;
    System.out.println("New Ticket No*** : "+newTicketTest);

    cs = conATG.prepareCall("{call AutoTicketSProcedure(?)}");

    cs.setString(1, newTicketTest);
    System.out.println(" conATG Before Exexute Query");

    // cs.registerOutParameter(1, Types.CHAR);
    cs.executeQuery();
    //String outParmTwo = rstATG.getString(1);
    // System.out.println("OutParam :"+outParmTwo);


    }catch (SQLException se){
    System.out.println("Error in TRY, control going to Catch in CursorATG() fn:" );
    se.printStackTrace();
    }
    //return rst1;
    }


    What is the Error why does it say 'No ResultSet was produced' is ther any problem in my SProcedure as i am using 2 Query inside the SP.

    I am really confused with the problem.I am expecting a reply from you all.




    Thanks and Regards
    Vikash Verma

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: Error in Stored Procedure, Error is: No ResultSet was produced in

    Originally posted by reachvikash1
    java.sql.SQLException: No ResultSet was produced
    at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeQue ry(JdbcOdbcPrepared
    Statement.java:97)
    at AutomaticTicketCursor.CursorATG(AutomaticTicketCur sor.java:254)
    at AutomaticTicketCursor.main(AutomaticTicketCursor.j ava:270)
    Main Fn()

    Your SP does not return a result set, so why do you use executeQuery()?

    I think this should work:
    Code:
    CallableStatement stmt = connection.prepareCall("call AutoTicketSProcedure(?)");
    stmt.setString(1, "whatever");
    stmt.execute();

Posting Permissions

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