SQL Server connection in Java Stored Procedures

Is it possible to establish a connection to microsoft sql server through java stored procedures. When I try to create a connetion to SQL Server I am getting the following exception in trace file
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java)
at java.sql.DriverManager.getConnection(DriverManager.java)
The connection details are correct and I am able to connect when I run the java code externally. Thanks in advance for the help

Can you connect to the MSSQL database from inside Oracle in (say) a SQL*Plus or SQL Developer session?
In other words, is the problem in the Java or the database linkages? Are you using Heterogeneous Services or Transparent Gateways?
Cheers, APC
blog: http://radiofreetooting.blogspot.com

Similar Messages

  • [Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'dbo.sp_SPNAMEHERE'.

    OK, something seemed to have changed with my system because this error is NEW. It might be related to my system upgrade from Vista to Win7, but just guessing here.
    I run a database on a corporate MS Sql Server (2005) and an ASP application that connects via ODBC. The real world application works fine, however when I attempt to access Stored Procedures from Dreamweaver (on my development machine)  I am getting the following error:
    [Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'dbo.sp_SPNAMEHERE'.
    This only seems to happen on Stored procedures that RETURN a recordset.
    system:
    Win7
    Dreamweaver CS4
    Code: VBScript/Classic ASP
    SQL Server 2005
    Connecting via ODBC: MM_MY_STRING = "Driver={SQL Server};Server=wscxxxxxxxxx;Database=dbsystem;Uid=username;Pwd=XXXXXXXXXXXX"
    Stored procedures that do not return a recordset are not an issue.... this has put my development work at a standstill!!
    Thanks in advance!

    Well, I hate bumps, but I am really running out of solutions. I have now tried to use a system DSN on my development machine and that didnt solve the problem. I just un-installed DW and re-installed it and that didnt solve my problem either.
    This is very frustrating, because I cannot use any stored procs that return recordsets... I am stuck... can anybody think of a relatively easy work-around to working in DW w/ recordsets that come from SPs when you cant actually access them?
    The really weird thing is, when I build the command, and choose the stored proc, and give it valid input variables, and TEST it from the TEST button, everything works and data is returned as expected. Once I click "OK" and actually add it to the ASP page the recordset that should be visible isnt... and when I click the plus sign in the bindings window I get the error...
    Help!!

  • Permissions needed for sql server job to execute stored procedure on linked server?

    Hi all
    I have a job step which attempts to call a stored procedure on a linked server.
    This step is failing with a permission denied error. How can I debug or resolve this?
    The job owner is sysadmin on both servers so should have execute permission to the database/proc I'm calling, right?
    The error is:
    The EXECUTE permission was denied on the object 'myProc', database 'myDatabase', schema 'dbo'. [SQLSTATE 42000] (Error 229).  The step failed.
    My code is:
    EXEC [LinkedServer].myDatabase.dbo.myProc
    Also tried:
    SELECT * FROM OPENQUERY([LinkedServer], 'SET FMTONLY OFF EXEC myDatabase.dbo.myProc')
    With the same result.
    Any help appreciated.

    The job owner may be sysadmin on the remote server. The service account for SQL Server Agent may not. And it is the latter that counts, since the it the service accounts that logs in and impersonates the job owner. But the impersonation inside SQL Server
    does not count much in Windows, and it is through Windows connection is made to the other site.
    One way to resolve this is to set up a login mapping for the job owner. The login mapping must be for an SQL login on the remote server.
    You can verify the theory, but running this query from the job:
       SELECT * FROM OPENQUERY([LinkedServer], 'SELECT SYSTEM_USER')
    By the way, putting SET FMTONLY OFF in OPENQUERY is a terrible idea. This has the effect that the procedure is executed twice. (Unless both servers are SQL 2012 or higher in which case FMTONLY has no effect at all.)
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Trying to report bug in SQL Server Replication with sp_MSdetect_nonlogged_shutdown stored procedure

    I've just tried to "Submit Feedback" but the page just gives me an error which means nothing to anyone which says "You are not authorized to submit the feedback for this connection.". Why am I not authorised how do I become authorised etc
    etc. Anyway :-)
    I've trying to report that the stored procedure in Sql Server Replication in 12.0.2000 has an issue with data type lengths. This procedure sp_MSdetect_nonlogged_shutdown uses data lengths of nvarchar(2048) but the MSDB sysjobhistory table has a message field
    length of 4000. Which causes the above stored procedure to crash.
    Best Regards
    Richard

    This is the work around
    1. Stop SQL Server service.
    2. On command prompt run the following command to run the server in single user mode – be sure to replace the MSSQLSERVER with the actual instance name
    C:\>”C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe” -sMSSQLSERVER -m
    3. Connect to SQL server with SSMS as the server administrator
    4. Run the following to change the database to the system resource database: “USE mssqlsystemresource”
    5. Run the following to update the stored procedure (only change is to make NVARCHAR(4000))
    SET ANSI_NULLS OFF
    GO
    SET QUOTED_IDENTIFIER OFF
    GO
    ALTER procedure [sys].[sp_MSdetect_nonlogged_shutdown]
        @subsystem nvarchar(60),
        @agent_id int
    as
    begin
        declare @job_id binary(16)
        declare @agent_name sysname
        declare @message nvarchar(4000)
        declare @retcode int
        declare @runstatus int
        declare @run_date int
        declare @run_time int
        declare @run_date_orig int
        declare @run_time_orig int
        declare @merge_session_id int
        -- security check
        -- only db_owner can execute this
        if (is_member ('db_owner') != 1) 
        begin
            raiserror(14260, 16, -1)
            return (1)
        end
        -- Detect if the agent was shutdown without a logged reason
        if UPPER(@subsystem collate SQL_Latin1_General_CP1_CS_AS) = 'SNAPSHOT'
        begin
            if exists (select runstatus from MSsnapshot_history where 
                agent_id = @agent_id and
                runstatus <> 2 and 
    --CAC       runstatus <> 5 and 
                runstatus <> 6 and
                timestamp = (select max(timestamp) from MSsnapshot_history where agent_id = @agent_id))
                begin
                    select @job_id = job_id, @agent_name = name from MSsnapshot_agents where id = @agent_id
                end
        end
        else if UPPER(@subsystem collate SQL_Latin1_General_CP1_CS_AS) = 'LOGREADER'
        begin
            if exists (select runstatus from MSlogreader_history where 
                agent_id = @agent_id and
                runstatus <> 2 and 
    --CAC           runstatus <> 5 and 
                runstatus <> 6 and
                timestamp = (select max(timestamp) from MSlogreader_history where agent_id = @agent_id))
                begin
                    select @job_id = job_id, @agent_name = name from MSlogreader_agents where id = @agent_id
                end
        end
        else if UPPER(@subsystem collate SQL_Latin1_General_CP1_CS_AS) = 'DISTRIBUTION'
        begin
            if exists (select runstatus from MSdistribution_history where 
                agent_id = @agent_id and
                runstatus <> 2 and 
    --CAC           runstatus <> 5 and 
                runstatus <> 6 and
                timestamp = (select max(timestamp) from MSdistribution_history where agent_id = @agent_id))
                begin
                    select @job_id = job_id, @agent_name = name from MSdistribution_agents where id = @agent_id
                end
        end
        else if UPPER(@subsystem collate SQL_Latin1_General_CP1_CS_AS) = 'MERGE'
        begin
            if exists (select runstatus from dbo.MSmerge_sessions where 
                agent_id = @agent_id and
                runstatus <> 2 and 
    --CAC           runstatus <> 5 and 
                runstatus <> 6 and
                session_id = (select top 1 session_id from dbo.MSmerge_sessions where agent_id = @agent_id order by session_id desc))
                begin
                    select @job_id = job_id, @agent_name = name from dbo.MSmerge_agents where id = @agent_id
                    select top 1 @merge_session_id = session_id from dbo.MSmerge_sessions 
    where agent_id = @agent_id 
    order by session_id desc
                end
        end
        else if UPPER(@subsystem collate SQL_Latin1_General_CP1_CS_AS) = 'QUEUEREADER'
        begin
            if exists (select runstatus from MSqreader_history where 
                agent_id = @agent_id and
                runstatus <> 2 and 
    --CAC       runstatus <> 5 and 
                runstatus <> 6 and
                timestamp = (select max(timestamp) from MSqreader_history where agent_id = @agent_id))
                begin
                    select @job_id = job_id, @agent_name = name from MSqreader_agents where id = @agent_id
                end
        end
        -- If no job_id assume shutdown was logged properly
        if @job_id is null
            return 0
        -- Get last message from SQL Agent History table
        create table #JobHistory (
            instance_id int NOT NULL, 
            job_id uniqueidentifier NOT NULL,
            job_name sysname NOT NULL,
            step_id int NOT NULL,
            step_name nvarchar(100) NOT NULL, 
            sql_message_id int NOT NULL,
            sql_severity int NOT NULL,
            message nvarchar(4000) NOT NULL,
            run_status int NOT NULL,
            run_date int NOT NULL,
            run_time int NOT NULL,
            run_duration int NOT NULL,
            operator_emailed sysname NULL,
            operator_netsent sysname NULL,
            operator_paged sysname NULL,
            retries_attempted int NOT NULL,
            server sysname NOT NULL
        if @@error <> 0
            return 1
        -- Insert last history for step_id 2 (Agent running)
        insert TOP(2) into #JobHistory exec sys.sp_MSreplhelp_jobhistory @job_id = @job_id, @step_id = 2, 
            @mode = 'FULL'          
    declare cursorHistory cursor local fast_forward for
        select message, 
        run_status,
        run_date,
        run_time
        from #JobHistory
        order by run_date desc, 
        run_time desc, 
        instance_id asc
        open cursorHistory
        fetch cursorHistory into @message, @runstatus, @run_date, @run_time
        select @run_date_orig = @run_date, 
      @run_time_orig = @run_time
        while @@fetch_status <> -1
        begin   
        -- as long as we are looking at the history for the same run 
        -- date and time then we should log all rows. there should 
        -- be 2 rows since we perform a TOP on exec sp_help_jobhistory
    if @run_date_orig = @run_date
      and @run_time_orig = @run_time
    begin
       -- Map SQL Agent runstatus to Replication runstatus
       set @runstatus = 
       case @runstatus
           when 0 then 6   -- Fail mapping
           when 1 then 2   -- Success mapping
           when 2 then 5   -- Retry mapping
           when 3 then 2   -- Shutdown mapping
           when 4 then 3   -- Inprogress mapping
           when 5 then 0   -- Unknown is mapped to never run
       end
       -- If no message, provide a default message
    -- Also overwrite all inprogress messages to be "See SQL Agent history log".
    -- This is to prevent "Agent running. See monitor" to be logged into repl monitor.
    -- In this case (the last job history message is InProgress), we know that
    -- there have been failures of SQL Server Agent history logging.
    -- In fact, the only possible "in progress" msg in SQL Agent job step
    -- history for push jobs is "Agent running. See monitor". It is confusing that those
    -- messages showed up in repl monitor.
       if @message is null or @runstatus = 3
       begin
           raiserror(20557, 10, -1, @agent_name)
           select @message = formatmessage(20557, @agent_name)
       end
       if UPPER(@subsystem collate SQL_Latin1_General_CP1_CS_AS) = 'SNAPSHOT'
           exec @retcode = sys.sp_MSadd_snapshot_history @agent_id = @agent_id, @runstatus = @runstatus,
                   @comments = @message
       else if UPPER(@subsystem collate SQL_Latin1_General_CP1_CS_AS) = 'LOGREADER'
           exec @retcode = sys.sp_MSadd_logreader_history @agent_id = @agent_id, @runstatus = @runstatus,
                   @comments = @message
       else if UPPER(@subsystem collate SQL_Latin1_General_CP1_CS_AS) = 'DISTRIBUTION'
           exec @retcode = sys.sp_MSadd_distribution_history @agent_id = @agent_id, @runstatus = @runstatus,
                   @comments = @message
       else if UPPER(@subsystem collate SQL_Latin1_General_CP1_CS_AS) = 'MERGE'
    exec @retcode = sys.sp_MSadd_merge_history @agent_id = @agent_id, @runstatus = @runstatus,
                   @comments = @message, @called_by_nonlogged_shutdown_detection_agent = 1, @session_id_override = @merge_session_id
       else if UPPER(@subsystem collate SQL_Latin1_General_CP1_CS_AS) = 'QUEUEREADER'
           exec @retcode = sys.sp_MSadd_qreader_history @agent_id = @agent_id, @runstatus = @runstatus,
                   @comments = @message
       if @@error <> 0 or @retcode <> 0
           return 1
    end
    fetch cursorHistory into @message, @runstatus, @run_date, @run_time
    end
    close cursorHistory
    deallocate cursorHistory
        drop table #JobHistory
    end
    6. Return the system resource database to read-only – “alter database mssqlsystemresource set read_only”
    7. Shutdown the instance – “shutdown”
    8. Start the instance using the service as usual

  • How to stop SQL Server Agent Job if Stored Procedure returns value 0

    I have SQL Server 2012 SSIS.
    I have 2 SSIS packages.
    I have created SQL Server Agent Job for running packages.
    I have created steps. If first step have run succesfully next step is run.
    I have need to add new logic.
    I have validation stored procedure, which validate DB table values and returns 1 or 0.
    I would like to create logic where first of all this SP is runned. Return value of SP determines if steps are run or not.
    I was thinking to use Execute SQL Task for running SP.
    If value 1 is returned, then run rest of Tasks is run.
    If value 0 is returned, what should I do so that Job is stopped? I need assistance! 
    I want current step to stop never moved to next step.
    Is there any SSIS tasks, which can stop the Job?
    Or should I make Step for running validation SP?
    How to do so that if value 0 is returned stop Job.
    Kenny_I

    Please refer the below link:
    http://technet.microsoft.com/en-us/library/aa260308(v=sql.80).aspx
    Please read Remarks carefully!!!
    Remarks
    If a job is currently executing a step of type CmdExec, the process being run (for example, MyProgram.exe) is forced to end prematurely. Premature ending can result in unpredictable behavior such as files in use by the process being held open. Consequently,
    sp_stop_job should be used only in extreme circumstances if the job contains steps of type CmdExec.
    Permissions
    Execute permissions default to the public role in the
    msdb database. A user who can execute this procedure and is a member of the
    sysadmin fixed role can stop any job. A user who is not a member of the
    sysadmin role can use sp_stop_job to stop only the jobs he/she owns.
    When sp_stop_job is invoked by a user who is a member of the
    sysadmin fixed server role, sp_stop_job will be executed under the security context in which the SQL Server service is running. When the user is not a member of the
    sysadmin group, sp_stop_job will impersonate the SQL Server Agent proxy account, which is specified using
    xp_sqlagent_proxy_account. If the proxy account is not available,
    sp_stop_job will fail. This is only true for Microsoft® Windows® NT 4.0 and Windows 2000. On Windows 9.x, there is no impersonation and
    sp_stop_job is always executed under the security context of the Windows 9.x user who started SQL Server.

  • SQL Server Service Broker Updating Stored procedure

    how can you update the service broker stored procedure. when i update the stored procedure the changes dont come into affect. i have tried to alter the queue, waited for all jobs to finish, but some how still the old stored procedure is running. is there any
    way i can force changes to the stored procedure.
    i have tried sql profiler tracing but that didnt show any changes.
    I cannot alter the service broker stored procedure, when I update the stored procedure it does not show any error and successfully gets updated but the changes does not come into affect.
    Is it because I need to stop the queue of the service broker on both databases before the changes could come into affect?
    Note: the service broker stored procedures produce and read xmls.

    Presumably, this is because the procedure is executing when you alter the procedure. And if the procedure never exits, the old code will keep on running. One way to address this is to have the procedure to return if a new message has not been picked up in,
    say, 1000 milliseconds.
    Here is a repro to shows what I'm talking about.
    ------------------------------- Service Broker Objects ------------------------------------------
    CREATE MESSAGE TYPE OrderRequest VALIDATION = NONE
    CREATE MESSAGE TYPE OrderResponse VALIDATION = NONE
    go
    CREATE CONTRACT OrderContract
       (OrderRequest SENT BY INITIATOR,
        OrderResponse SENT BY TARGET)
    go
    CREATE QUEUE OrderRequests WITH STATUS = OFF
    CREATE QUEUE OrderResponses WITH STATUS = ON
    go
    CREATE SERVICE OrderRequests ON QUEUE OrderRequests (OrderContract)
    CREATE SERVICE OrderResponses ON QUEUE OrderResponses (OrderContract)
    go
    -- Procedure to send a message and receive a response.
    CREATE PROCEDURE send_and_get_answer AS
    DECLARE @handle uniqueidentifier,
             @binary varbinary(MAX)
          SELECT @binary = CAST (N'Kilroy was here' AS varbinary(MAX))
          BEGIN DIALOG CONVERSATION @handle
          FROM  SERVICE OrderResponses
          TO    SERVICE 'OrderRequests'
          ON    CONTRACT OrderContract
          WITH ENCRYPTION = OFF
          ;SEND ON CONVERSATION @handle
          MESSAGE TYPE OrderRequest (@binary)
       WAITFOR (RECEIVE TOP (1)
                         @handle = conversation_handle,
                         @binary = message_body
                FROM    OrderResponses)
       SELECT cast(@binary AS nvarchar(MAX)) AS response
       END CONVERSATION @handle
    go
    -- Procedure to process a message
    CREATE PROCEDURE ProcessOrders AS
    SET NOCOUNT, XACT_ABORT ON
    DECLARE @DialogHandle  uniqueidentifier,
            @MessageType   sysname,
            @binarydata    varbinary(MAX)
    -- Get next message of the queue.
    WAITFOR (
       RECEIVE TOP (1) @DialogHandle = conversation_handle,
                         @MessageType  = message_type_name,
                         @binarydata   = message_body
       FROM    OrderRequests
    SELECT @binarydata = CAST( reverse( CAST( @binarydata AS nvarchar(MAX) )) AS varbinary(MAX))
    ; SEND ON CONVERSATION @DialogHandle
    MESSAGE TYPE OrderResponse (@binarydata)
    END CONVERSATION @DialogHandle
    go       
    -- Make this an activaton procedure.
    ALTER QUEUE OrderRequests WITH
          STATUS = ON,
          ACTIVATION (STATUS = ON,
                      PROCEDURE_NAME = ProcessOrders,
                      MAX_QUEUE_READERS = 1,
                      EXECUTE AS OWNER)
    go
    -------------------------------- Send a message  -------------------------------------------
    EXEC send_and_get_answer
    go
    ------------------------ Change the procedure --------------------------------
    ALTER PROCEDURE ProcessOrders AS
    SET NOCOUNT, XACT_ABORT ON
    DECLARE @DialogHandle  uniqueidentifier,
            @MessageType   sysname,
            @binarydata    varbinary(MAX)
    -- Get next message of the queue.
    WAITFOR (
       RECEIVE TOP (1) @DialogHandle = conversation_handle,
                         @MessageType  = message_type_name,
                         @binarydata   = message_body
       FROM    OrderRequests
    SELECT @binarydata = CAST( upper( CAST( @binarydata AS nvarchar(MAX) )) AS varbinary(MAX))
    ; SEND ON CONVERSATION @DialogHandle
    MESSAGE TYPE OrderResponse (@binarydata)
    END CONVERSATION @DialogHandle
    go
    -------------------------------- Send new message -------------------------------------------
    EXEC send_and_get_answer    -- Still produces a message in reverse.
    EXEC send_and_get_answer    -- Now we get the expected result.
    go
    DROP SERVICE OrderRequests
    DROP SERVICE OrderResponses
    DROP QUEUE OrderRequests
    DROP QUEUE OrderResponses
    DROP PROCEDURE ProcessOrders
    DROP PROCEDURE send_and_get_answer
    DROP CONTRACT OrderContract
    DROP MESSAGE TYPE OrderRequest
    DROP MESSAGE TYPE OrderResponse
    go
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Bug? SQL server 7 - Oracle 8i stored procedures

    I'm having a problem converting some SQL 7 stored procedures to Oracle using MW. The cursor definition appears to be garbage in some cases. See example as follows:
    *********** SQL 7 stored procedure *********
    CREATE PROCEDURE CLCClaim
    /* Procedure: CLCClaim */
    /* Description: Cascading delete to child tables */
    /* Table: CLClaim */
    /* Generated: 4/23/01 2:31:21 PM */
    @AuditUserId int,
    @AuditLctn varchar(20),
    @ClaimId int
    AS
    DECLARE
    @Trncnt int,
    @ErrorNumber int,
    @Id int,
    @Rows int,
    @ClsnId int
    SELECT @ErrorNumber = -1
    /* Save transaction count value */
    SELECT @Trncnt = @@TRANCOUNT
    /* Issue begin transaction if not already in a transaction */
    If @Trncnt = 0
    BEGIN TRANSACTION T1
    /* Build a cursor for finding child CLClaimAtchm rows */
    DECLARE CLClaimAtchmCursor Cursor For
    SELECT ClaimAtchmId, ClsnId
    FROM dbo.CLClaimAtchm
    WHERE ClaimId = @ClaimId
    /* Open the cursor */
    OPEN CLClaimAtchmCursor
    SELECT @ErrorNumber = @@ERROR
    If @ErrorNumber <> 0 GoTo ErrorHandler
    FETCH Next
    FROM CLClaimAtchmCursor
    INTO @Id, @ClsnId
    ... more follows, but this is the gist of it
    **** Oracle Procedure created by MW
    CREATE OR REPLACE PROCEDURE CLCClaim(
    AuditUserId NUMBER ,
    AuditLctn VARCHAR2 ,
    ClaimId NUMBER )
    AS
    StoO_selcnt INTEGER;
    StoO_error INTEGER;
    StoO_rowcnt INTEGER;
    StoO_crowcnt INTEGER := 0;
    StoO_fetchstatus INTEGER := 0;
    StoO_errmsg VARCHAR2(255);
    StoO_sqlstatus INTEGER;
    Trncnt NUMBER(10,0);
    ErrorNumber NUMBER(10,0);
    Id NUMBER(10,0);
    Rows_ NUMBER(10,0);
    ClsnId NUMBER(10,0);
    CURSOR CLClaimAtchmCursor IS SELECT omwb_emulation.globalPkg.trancount
    FROM CLClaimAtchm
    WHERE ClaimId = CLCClaim.ClaimId;
    CURSOR CLClaimDiagCursor IS SELECT StoO_error
    FROM CLClaimDiag
    WHERE ClaimId = CLCClaim.ClaimId;
    CURSOR CLClaimAdjdCursor IS SELECT StoO_error
    FROM CLClaimAdjd
    WHERE ClaimId = CLCClaim.ClaimId;
    CURSOR CLSvcLineCursor IS SELECT StoO_error
    FROM CLSvcLine
    WHERE ClaimId = CLCClaim.ClaimId;
    /* Procedure: CLCClaim */
    /* Description: Cascading delete to child tables */
    /* Table: CLClaim */
    /* Generated: 4/23/01 2:31:21 PM */
    /* Save transaction count value */
    BEGIN
    CLCClaim.ErrorNumber := -1;
    /* Issue begin transaction if not already in a transaction */
    CLCClaim.Trncnt := omwb_emulation.globalPkg.trancount;
    IF CLCClaim.Trncnt = 0 THEN
    /* Build a cursor for finding child CLClaimAtchm rows */
    /* Emulating @@TRANCOUNT functionality in Oracle model */
    omwb_emulation.globalPkg.trancount:=omwb_emulation.globalPkg.trancount+1;
    SAVEPOINT T1;
    END IF;
    NULL;/*DECLARE CURSOR CLClaimAtchmCursor */
    /* Open the cursor */
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    StoO_crowcnt := 0;
    OPEN CLClaimAtchmCursor;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    END;
    CLCClaim.ErrorNumber := StoO_error;
    IF CLCClaim.ErrorNumber <> 0 THEN
    GOTO ErrorHandler;
    END IF;
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    StoO_crowcnt := 0;
    FETCH CLClaimAtchmCursor INTO CLCClaim.Id, CLCClaim.ClsnId;
    EXCEPTION
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    END;
    ...more follows, but the error is in the SELECT clause of the CURSOR declaration
    I'm having to manually fix the CURSOR declarations for these converted procedures.
    Is there a fix or workaround to prevent me from growing my collection of gray hairs?
    Thanks,
    Billy Smith

    William,
    I did a quick check on our latest code and got the following output:
    CREATE OR REPLACE PROCEDURE CLCClaim(
    AuditUserId INTEGER DEFAULT NULL,
    AuditLctn VARCHAR2 DEFAULT NULL,
    ClaimId INTEGER DEFAULT NULL)
    AS
    StoO_selcnt INTEGER;
    StoO_error INTEGER;
    StoO_rowcnt INTEGER;
    StoO_crowcnt INTEGER := 0;
    StoO_fetchstatus INTEGER := 0;
    StoO_errmsg VARCHAR2(255);
    StoO_sqlstatus INTEGER;
    Trncnt INTEGER;
    ErrorNumber INTEGER;
    Id INTEGER;
    Rows INTEGER;
    ClsnId INTEGER;
    CURSOR CLClaimAtchmCursor IS
    SELECT ClaimAtchmId, ClsnId
    FROM /*standalone*/sa.CLClaimAtchm
    WHERE ClaimId = CLCClaim.ClaimId;
    /* Procedure: CLCClaim */
    /* Description: Cascading delete to child tables */
    /* Table: CLClaim */
    /* Generated: 4/23/01 2:31:21 PM */
    /* Save transaction count value */
    BEGIN
    CLCClaim.ErrorNumber := -1;
    /*[SPCONV-ERR(26)]:('@TRANCOUNT') Global Variable treated as variable*/
    /* Issue begin transaction if not already in a transaction */
    CLCClaim.Trncnt := CLCClaim.TRANCOUNT;
    IF CLCClaim.Trncnt = 0 THEN
    /* Build a cursor for finding child CLClaimAtchm rows */
    SAVEPOINT T1;
    END IF;
    NULL;/*DECLARE CURSOR CLClaimAtchmCursor */
    /* Open the cursor */
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    StoO_crowcnt := 0;
    OPEN CLClaimAtchmCursor;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    END;
    CLCClaim.ErrorNumber := StoO_error;
    IF CLCClaim.ErrorNumber <> 0 THEN
    GOTO ErrorHandler;
    END IF;
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    StoO_crowcnt := 0;
    FETCH CLClaimAtchmCursor INTO
    CLCClaim.Id, CLCClaim.ClsnId;
    EXCEPTION
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    END;
    IF CLClaimAtchmCursor%NOTFOUND THEN
    StoO_sqlstatus := 2;
    StoO_fetchstatus := -1;
    ELSE
    StoO_sqlstatus := 0;
    StoO_fetchstatus := 0;
    END IF;
    END CLCClaim;
    If this is not sufficient please give a complete testcase and migration workbench version to support email address: [email protected] so the bug can be reproduced and logged.
    Turloch
    Oracle Migration Workbench Team

  • Connecting to SQL Server and MYSQL from a Java stored procedure

    hope someone can help with this. i'm trying to connect to different databases (My SQL, SQL Server) from a java stored procedure. when invoking from within an oracle 9i database, i get the java exception error -
    "Cannot connect to MySQL server on 135.177.196.75:3306. Is there a MySQL server running on the machine/port you are trying to connect to?java.security.AccessControlException)".
    this store procedure works fine when invoked from outside of oracle. any replies would be greatly appreciated. thanks!

    the correct drivers have been loaded. it works when called from outside of oracle. only when invoking from within oracle do we get the error message "Cannot connect to MySQL server on 135.177.196.75:3306. Is there a MySQL server running on the machine/port you are trying to connect to?(java.security.AccessControlException)". it sounds like a permissions/security/configuration issue - oracle is not allowing access to the machine/port for the MySQL or SQL Server database. appreciate the responses so far.

  • Out of memory error when calling a java stored procedure multiple times

    Trying to run a PL/SQL loop calling a java stored procedure, I get the following error:
    "ORA-04030: out of process memory when trying to allocate 262188 byte callheap,ioc_allocate free)"
    (with some other error lines).
    The stored procedure does two major things:
    1) Open a socket to communicate with a server, of which it queries some data.
    2) Use JDBC (with the default DB connection it has, as a stored procedure) to write the results to a table.
    All socket connections, statements, etc. are properly closed and all memory should be garbage collected between each call.
    Can anyone offer an explanation or additional checks to make? I'm quite sure the code isn't causing the problem, since I've tried running it as a stand alone application (outside of Oracle) and didn't have any problems.
    Thanks.

    Hi,
    Verify that the database parameters are set correctly.
    EA

  • Passing Tables back from Java Stored Procedures

    Thomas Kyte has written (in reference to
    trying to pass an array back from a stored
    function call):
    You can do one of two things (and both require the use of
    objects). You cannot use PLSQL table types as JDBC cannot bind to
    this type -- we must use OBJECT Types.
    [snip]
    Another way is to use a result set and "select * from
    plsql_function". It could look like this:
    ops$tkyte@8i> create or replace type myTableType as table of
    varchar2 (64);
    2 /
    Type created.
    ops$tkyte@8i>
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace
    2 function demo_proc2( p_rows_to_make_up in number )
    3 return myTableType
    4 as
    5 l_data myTableType := myTableType();
    6 begin
    7 for i in 1 .. p_rows_to_make_up
    8 loop
    9 l_data.extend;
    10 l_data(i) := 'Made up row ' &#0124; &#0124; i;
    11 end loop;
    12 return l_data;
    13 end;
    14 /
    Function created.
    ops$tkyte@8i>
    ops$tkyte@8i> select *
    2 from the ( select cast( demo_proc2(5) as mytableType )
    3 from dual );
    COLUMN_VALUE
    Made up row 1
    Made up row 2
    Made up row 3
    Made up row 4 [Image]
    Made up row 5
    So, your JDBC program would just run the query to get the data.
    If the function "demo_proc2" cannot be called from SQL for
    whatever reason (eg: it calls an impure function in another piece
    of code or it itself tries to modify the database via an insert
    or whatever), you'll just make a package like:
    ops$tkyte@8i> create or replace package my_pkg
    2 as
    3
    4 procedure Make_up_the_data( p_rows_to_make_up in
    number ); 5 function Get_The_Data return myTableType;
    6 end;
    7 /
    Package created.
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace package body my_pkg
    2 as
    3
    4 g_data myTableType;
    5
    6 procedure Make_up_the_data( p_rows_to_make_up in number )
    7 as
    8 begin
    9 g_data := myTableType();
    10 for i in 1 .. p_rows_to_make_up
    11 loop
    12 g_data.extend;
    13 g_data(i) := 'Made up row ' &#0124; &#0124; i;
    14 end loop;
    15 end;
    16
    17
    18 function get_the_data return myTableType
    19 is
    20 begin
    21 return g_data;
    22 end;
    23
    24 end;
    25 /
    Package body created.
    ops$tkyte@8i>
    ops$tkyte@8i> exec my_pkg.make_up_the_data( 3 );
    PL/SQL procedure successfully completed.
    ops$tkyte@8i>
    ops$tkyte@8i> select *
    2 from the ( select cast( my_pkg.get_the_data as mytableType
    ) 3 from dual );
    COLUMN_VALUE
    Made up row 1
    Made up row 2
    Made up row 3
    And you'll call the procedure followed by a query to get the
    data...
    I have tried this, and it works perfectly.
    My question, is what does the wrapper look
    like if the stored function is written
    in java instead of PL/SQL? My experiments
    with putting the function in java have been
    dismal failures. (I supposed I should also
    ask how the java stored procedure might
    look also, as I suppose that could be where
    I have been having a problem)
    null

    Thanks for the response Avi, but I think I need to clarify my question. The articles referenced in your link tended to describe using PL/SQL ref cursors in Java stored procedures and also the desire to pass ref cursors from Java to PL/SQL programs. Unfortunately, what I am looking to do is the opposite.
    We currently have several Java stored procedures that are accessed via select statements that have become a performance bottleneck in our system. Originally the business requirements were such that only a small number of rows were ever selected and passed into the Java stored procedures. Well, business requirements have changed and now thousands and potentially tens of thousands of rows can be passed in. We benchmarked Java stored procedures vs. PL/SQL stored procedures being accessed via a select statement and PL/SQL had far better performance and scaleable. So, our thought is by decouple the persistence logic into PL/SQL and keeping the business logic in Java stored procedures we can increase performance without having to do a major rewrite of the existing code. This leads to the current problem.
    What we currently do is select into a Java stored procedure which has many database access calls. What we would like to do is select against a PL/SQL stored procedure to aggregate the data and then pass that data via a ref cursor (or whatever structure is acceptable) to a Java stored procedure. This would save us a significant amount of work since the current Java stored procedures would simple need to be changed to not make database calls since the data would be handed to them.
    Is there a way to send a ref cursor from PL/SQL as an input parameter to a Java stored procedure? My call would potentially look like this:
    SELECT java_stored_proc(pl/sql_stored_proc(col_id))
    FROM table_of_5000_rows;
    Sorry for the lengthy post.

  • ODBC Error connecting to a stored procedure SQL Server 2008 - Crystal 8.5

    I am running a local copy of SQL server 2008 and get an ODBC error when connecting to any stored procedure with or without parameter. The database are running in SQL Server 2000 compatibility mode on the local server.
    Do not get the error when connecting to one or more databse tables or when connecting to a stored procedure on a remote database.
    The error reported is "ODBC error:[Microsoft][ODBC SQL Server driver] Syntax error or access violation"
    I am running Vista OS.
    Any help would be appreciated..

    Hello,
    Interesting combination. All but CR 8.5 is supported on that OS.
    When you created your DSN did you using the 2008 Client or MDAC?
    I suggest you go back to supported platforms for CR 8.5
    If not then start debugging Vista permissions to start with...
    good luck
    Don

  • Java Stored Procedure / connection JDBC / Server Side / Client Side

    Hi,
    I would like to know if we can know at the runtime with a JDBC api if the stored procedure is running in client side or in server side ?
    THANKS

    You wrote
    "Java stored procedures -- by definition - are stored in the 8i rdbms. !!"
    From the Oracle8i Java Stored Procedures Developer's Guide
    Release 8.1.5
    A64686-01
    "If you create Java class files on the client side, you can use loadjava to upload them into the RDBMS. Alternatively, you can upload Java source files and let the Aurora JVM compile them. In most cases, it is best to compile and debug programs on the client side, then upload the class files for final testing within the RDBMS"
    This means that you can create shared classes that are used on both the client and server side. The source does not need to reside within the server (according to their documentation). Please also note the following from the Oracle8i JDBC Developer's Guide and Reference Release 8.1.5 A64685-01 for using the getConnection() method on the server:
    "If you connect to the database with the DriverManager.getConnection() method, then use the connect string jdbc:oracle:kprb:. For example:
    DriverManager.getConnection("jdbc:oracle:kprb:");
    Note that you could include a user name and password in the string, but because you are connecting from the server, they would be ignored."
    So if you're coding a shared class that is to run on both the client and server side, you might do something like this:
    Connection conn =
    DriverManager.getConnection(
    System.getProperty("oracle.server.version") == null
    ? "jdbc:oracle:thin:@hostname:1521:ORCL"
    : "jdbc:oracle:kprb:"),
    "youruserid","yourpassword");
    As stated earlier, the userid and password are supposedly ignored for server connections retrieved in this manner. I haven't tried this yet, but it is documented by Oracle.
    Regards,
    Steve
    null

  • Java Stored Procedure / Server Side / Client Side / connection

    Hi,
    I would like to know if we can know at the runtime with a JDBC api if the stored procedure is running in client side or in server side ?
    THANKS

    You wrote
    "Java stored procedures -- by definition - are stored in the 8i rdbms. !!"
    From the Oracle8i Java Stored Procedures Developer's Guide
    Release 8.1.5
    A64686-01
    "If you create Java class files on the client side, you can use loadjava to upload them into the RDBMS. Alternatively, you can upload Java source files and let the Aurora JVM compile them. In most cases, it is best to compile and debug programs on the client side, then upload the class files for final testing within the RDBMS"
    This means that you can create shared classes that are used on both the client and server side. The source does not need to reside within the server (according to their documentation). Please also note the following from the Oracle8i JDBC Developer's Guide and Reference Release 8.1.5 A64685-01 for using the getConnection() method on the server:
    "If you connect to the database with the DriverManager.getConnection() method, then use the connect string jdbc:oracle:kprb:. For example:
    DriverManager.getConnection("jdbc:oracle:kprb:");
    Note that you could include a user name and password in the string, but because you are connecting from the server, they would be ignored."
    So if you're coding a shared class that is to run on both the client and server side, you might do something like this:
    Connection conn =
    DriverManager.getConnection(
    System.getProperty("oracle.server.version") == null
    ? "jdbc:oracle:thin:@hostname:1521:ORCL"
    : "jdbc:oracle:kprb:"),
    "youruserid","yourpassword");
    As stated earlier, the userid and password are supposedly ignored for server connections retrieved in this manner. I haven't tried this yet, but it is documented by Oracle.
    Regards,
    Steve
    null

  • Java Stored Procedures + oralce.xdb.XMLType + initxdbj.sql

    In order to use XMLType object in java stored procedures, I need to import oralce.xdb.XMLType package. I got compiler error saying "Class oracle.xdb.XMLType not found" (See List1).
    I check my installed package, sure enough these is no "oracle/xdb/XMLType" or any xdb related one. (See list2) This surprises me since my 9i/Solaris installation was successful and spotless one.
    The 9i App Dev - XML doc states that script $ORACLE_HOME/rdbms/admin/initxdbj.sql could install that package. (See List3) The fact is no way this script could be found from Oracle901/Solaris8 or Oracle901/NT installations.
    If java program moved to client and included xdb_g.jar in CLASSPATH, then it is fine as Doc declares. It just failed to compile in server as stored procedures.
    Please help, Thanks.
    Andy Ting DBA (301)240-2223, [email protected]

    (now include Listings)
    In order to use XMLType object in java stored procedures, I need to import oralce.xdb.XMLType package. I got compiler error saying "Class oracle.xdb.XMLType not found" (See List1).
    I check my installed package, sure enough these is no "oracle/xdb/XMLType" or any xdb related one. (See list2) This surprises me since my 9i/Solaris installation was successful and spotless one.
    The 9i App Dev - XML doc states that script $ORACLE_HOME/rdbms/admin/initxdbj.sql could install that package. (See List3) The fact is no way this script could be found from Oracle901/Solaris8 or Oracle901/NT installations.
    If java program moved to client and included xdb_g.jar in CLASSPATH, then it is fine as Doc declares. It just failed to compile in server as stored procedures.
    Please help, Thanks.
    Andy Ting DBA (301)240-2223, [email protected]
    ====================================================================
    List 1:
    sql> select NAME,TYPE,SEQUENCE,LINE,substr(text,1,80) TEXT from user_errors order BY 1,2,3,4
    NAME TYPE SEQUENCE LINE
    TEXT
    proto4a/database/XMLTypeTest JAVA CLASS 1 0
    ORA-29535: source requires recompilation
    proto4a/database/XMLTypeTest JAVA SOURCE 1 0
    proto4a/database/XMLTypeTest:11: Class oracle.xdb.XMLType not found in import.
    proto4a/database/XMLTypeTest JAVA SOURCE 2 0
    proto4a/database/XMLTypeTest:12: Class XMLTYPE not found in import.
    proto4a/database/XMLTypeTest JAVA SOURCE 3 0
    Info: 2 errors
    ==============================================================
    List 2:
    sql> select OWNER,OBJECT_NAME,OBJECT_TYPE from all_objects
    where upper(object_name) like '%XMLTYPE%';
    OWNER OBJECT_NAME OBJECT_TYP
    SYS /219cdace_AQxmlTypeInfoRespons JAVA CLASS
    /a341e963_AQxmlTypeInfoRequest
    XMLTYPE TYPE
    XMLTYPE TYPE BODY
    XMLTYPE_LIB LIBRARY
    PUBLIC /219cdace_AQxmlTypeInfoRespons SYNONYM
    /a341e963_AQxmlTypeInfoRequest
    sql> select OWNER,OBJECT_NAME,OBJECT_TYPE from all_objects
    where upper(object_name) like '%XDB%';
    no rows selected
    ====================================================================
    List 3:
    Installing and using oracle.xdb.XMLType class
    The oracle.xdb.XMLType is available in the xdb_g.jar file in the ORACLE_
    HOME/rdbms/jlib where ORACLE_HOME refers to the Oracle home directory.
    Using oracle.xdb.XMLType inside JServer:
    This class is pre-loaded in to the JServer and is available in the SYS schema.
    It is not loaded however, if you have upgraded your database from an earlier
    version. If you need to upload the class into the JServer, you would need to run the
    initxdbj.sql file located in the ORACLE_HOME/rdbms/admin directory, while
    connected as SYS.
    Using oracle.xdb.XMLType on the client:
    If you need to use the oracle.xdb.XMLType class on the client side, then ensure that
    the xdb_g.jar file is listed in your CLASSPATH environment variable.
    =====================================================================

  • APEX fails with Java stored procedure that creates a JDBC connection

    Hello!
    We are facing a strange problem since we have upgraded from Oracle 10g and Apache to Oracle 11g with Embedded Gateway.
    Here is what we do:
    ** APEXX calls a PL/SQL package function "OPEN_CONNECTION" that wraps a Java stored procedure called "openConnection".*
    FILE_READER_REMOTE_API.openConnection(user, password, host, port, service);
    ** The Java stored procedures "openConnection" opens a JDBC connection to an other database:*
    public class FileReaderRemote {
    private static Connection conn = null;
    private static DefaultContext remoteContext = null;
    public static void openConnection(String user, String password, String host, String port, String service) throws SQLException {
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    java.util.Properties props = new java.util.Properties();
    props.put ("user", user);
    props.put ("password", password);
    //props.put ("database", "//" + host + ":" + port + "/" + service);
    props.put ("database", host + ":" + port + ":" + service);
    props.put("v$session.program", "FileReaderRemote2");
    // Connect to the database
    remoteContext = Oracle.getConnection("jdbc:oracle:thin:", props);
    This procedure used to work fine before the upgrade, but now we see the following:
    * It still works when called directly from TOAD or SQL*Plus, even under the user ANONYMOUS.
    * When called from APEX and the target database is Oracle 11g, it still works.
    * When called from APEX and the target database is Oracle 10g, it takes several minutes and we receive this error:
    *"Socket read timed out"*
    We have tested the following workaround:
    We have created a database link to our own database and called the stored procedure through that database link.
    FILE_READER_REMOTE_API.openConnection*@loopback*(user, password, host, port, service);
    This works, but is not really an option.
    I hope some one of you can explain this strange behaviour to me.
    Best regards,
    Matthias

    You wrote
    "Java stored procedures -- by definition - are stored in the 8i rdbms. !!"
    From the Oracle8i Java Stored Procedures Developer's Guide
    Release 8.1.5
    A64686-01
    "If you create Java class files on the client side, you can use loadjava to upload them into the RDBMS. Alternatively, you can upload Java source files and let the Aurora JVM compile them. In most cases, it is best to compile and debug programs on the client side, then upload the class files for final testing within the RDBMS"
    This means that you can create shared classes that are used on both the client and server side. The source does not need to reside within the server (according to their documentation). Please also note the following from the Oracle8i JDBC Developer's Guide and Reference Release 8.1.5 A64685-01 for using the getConnection() method on the server:
    "If you connect to the database with the DriverManager.getConnection() method, then use the connect string jdbc:oracle:kprb:. For example:
    DriverManager.getConnection("jdbc:oracle:kprb:");
    Note that you could include a user name and password in the string, but because you are connecting from the server, they would be ignored."
    So if you're coding a shared class that is to run on both the client and server side, you might do something like this:
    Connection conn =
    DriverManager.getConnection(
    System.getProperty("oracle.server.version") == null
    ? "jdbc:oracle:thin:@hostname:1521:ORCL"
    : "jdbc:oracle:kprb:"),
    "youruserid","yourpassword");
    As stated earlier, the userid and password are supposedly ignored for server connections retrieved in this manner. I haven't tried this yet, but it is documented by Oracle.
    Regards,
    Steve
    null

Maybe you are looking for

  • IPhone 4 -IOS 7.1.2 Voice Memos Starting Screen Bug

    Voice memos comes to face me like this when I stepped to the screen.My phone not charge You should look at the top right side

  • Problem integrating BPEL with OID

    Hey, We are setting BPEL up to work with collabsuite mid-tier. When applying the configuration steps in the ContentServices_CustomWorkflows.html provided in the devkit we run into the following problem: Change to perform: Create the Service-to-Servic

  • Sending vocal tracks to an Aux channel with reverb

    Sorry for this question that may have been answered somewhere else. I'm trying to add a single reverb plug-in to 6 vocal tracks. I've bussed all 6 to an Aux channel via bus 1, setting the input of the Aux channel to bus 1. No sound. I can't seem to f

  • Using multiple SSIDs with same name but different PSKs

    I have a central WLC 2504 controller that is being used for remote site FlexConnect 1141 APs. They all advertise three different SSIDs. One SSID is a global SSID that is the same at every office. One is a hidden SSID using 802.1x machine auth. The on

  • IPod plays music through the speaker on the back

    Hi, My new iPod nano 5th generation seems to play music through the back speaker for the camera and voiceover options. When i plug in my headphones, it will play through those, as well as the speaker, but even when I unplug the headphones, it plays t