Unable to catch raiseerror exception from MS SQL Server Exception in hibernate

I am using raiseerror in MS SQL Server exception to throw customized error and it is working fine in database.
But, I am unable to catch MS SQL Server Exception in hibernate. Please find the database & java syntax below.
SQL Server Syntax:-
    ALTER PROCEDURE [grantiumSQL].[ERROR_MESSAGE]
    @ERRMSG NVARCHAR(4000)
    AS
    BEGIN
    -- Return if there is no error information to retrieve.    
    IF ERROR_NUMBER() IS NULL    
        RETURN;    
    DECLARE     
        @ErrorMessage    NVARCHAR(4000),    
        @ErrorNumber     INT,    
        @ErrorSeverity   INT,    
        @ErrorState      INT,    
        @ErrorLine       INT,    
        @ErrorProcedure  NVARCHAR(200);    
    -- Assign variables to error-handling functions that     
    -- capture information for RAISERROR.    
    SELECT     
        @ErrorNumber = ERROR_NUMBER(),    
        @ErrorSeverity = ERROR_SEVERITY(),    
        @ErrorState = ERROR_STATE(),    
        @ErrorLine = ERROR_LINE(),    
        @ErrorProcedure = ISNULL(ERROR_PROCEDURE(), '-'),   
        @ErrorMessage = @ERRMSG
    RAISERROR     
        @ErrorMessage,    
        @ErrorSeverity,     
        1                           
        )WITH NOWAIT;
    END;
Java Syntax:-
public void callDeleteStoreProcedure(int workflowProjectId,String status){
  boolean shouldCommit = HibernateUtil.beginTxn();
  Session session = HibernateUtil.currentSession();
  try
  // query = session.getNamedQuery("deleteWorkflowProject_ora");
  Query callStoredProcedure = session.createSQLQuery("{PROCEDUR_NAME(?,?)}");
  callStoredProcedure.setInteger(0, prj);
  callStoredProcedure.setString(1, status);
  callStoredProcedure.executeUpdate();
     }catch (HibernateException e) {
     e.printStackTrace();
  catch (Exception e) {
      e.printStackTrace();
  HibernateUtil.commitTxn(shouldCommit);
Thanks in advance

HI! We have the same problem. Have you manage to resolve it?

Similar Messages

  • How to delete a row from a SQL Server CE Table with multiple JOINs?

    I want to delete a record from a SQL Server CE table.
    There are 3 tables scripts, options and results. I would like to remove a record from the results table. The where clause contains dynamic information which retrieved via other queries to different tables in the same database. These queries work fine and deliver
    the desired data.
    The Compact server is a clone of a remote table created using the sync framework. The same query to the remote table works fine.
    The error I get is:
    There was an error parsing the query. [ Token line number = 1,Token line offset = 10,Token in error = from ]
    The code that throws the exception is as follows:
    Dim connLoc As SqlCeConnection = New SqlCeConnection(My.Settings.ConnectionString)connLoc.Open()     Dim strDel As String = "Delete r from ResultsTable r inner join OptionsTable o ON o.TestName=r.TestName inner join ScriptTable c ON r.TestName=c.TestName WHERE r.TestName = '" & ds1Loc.Tables(0).Rows(0)(1) & "' AND [Index] = '" & lstIndex & "'"Dim cmdDel As SqlCeCommand = New SqlCeCommandcmdDel.CommandText = strDelcmdDel.Connection = connLoccmdDel.ExecuteNonQuery()
    The values held in ds1Loc.Tables(0).Rows(0)(1) and lstIndex are
    correct so should not be the problem.
    I also tried using parameterised queries
    Dim strDel As String = "Delete r from [ResultsTable] r inner join [OptionsTable] o ON o.TestName=r.TestName inner join [ScriptTable] c ON r.TestName=c.TestName WHERE r.TestName = @TestName AND [Index] = @lstIndex"
    Dim cmdDel As SqlCeCommand = New SqlCeCommand        cmdDel.CommandText = strDel       
    With cmdDel.Parameters           
    .Add(New SqlCeParameter("@TestName", ds1Loc.Tables(0).Rows(0)(1)))           
    .Add(New SqlCeParameter("@lstIndex", lstIndex))       
    End With 
    cmdDel.Connection = connLoc        cmdDel.ExecuteNonQuery()
    I have tried replacing the "=" with "IN" in the the WHERE clause but this has not worked.
    Is it the join that is causing the problem? I can do a select with the same search criteria and joins from the same database.
    Also this query works with SQL Server. Is it perhaps that SQL CE does not support the Delete function the same as SQL Server 2008? I have been looking at this for a while now and cannot find the source of the error. Any help would be greatly appreciated.

    Hello,
    In SQL Server Compact, we can use join in FROM clause. The DELETE statement fail may be caused by the FOREIGN KEY constraint.
    Please refer to:
    DELETE (SQL Server Compact)
    FROM Clause (SQL Server Compact)
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • JAVA, sqlserver - Need to load an image from the sql server database

    hi,
    I need to load an image from the sql server database using java. I have connected to the database and getting all other records except the records for a photo (datatype = LONGVARBINARY) and Remarks (datatype = LONGVARCHAR).
    I am using java and sql server db. The photo and remarks are stored in the db. and i need to show the image and the remarks fetching them from there.
    I get the error :
    Thread-9 org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
    How can I achieve this?
    Thanks,
    Gargi

    Exactly. And are you using MySQL?
    No. You are using Microsoft SQL server if I have to believe your initial post. A quick google tells me that the dialect class to use is:
    org.hibernate.dialect.SQLServerDialect

  • Migration from MS SQL Server 7.0 to ORACLE 7.3

    I am unable to download WorkBench. Does it support the migration from MS SQL Server 7.0 to ORACLE 7.3 anyway.

    Actually, I have to do the conversion from MS SQL Server 7.0 to ORACLE 7.3. I am thinking to do migration firt then do the conversion by writing the packages. Is there any other way to do it......
    I am unable to download WorkBench. Does it support the migration from MS SQL Server 7.0 to ORACLE 7.3 anyway.

  • Exception :DBD, [Microsoft][SQL server] ..State: 42000

    Hi All,
    I have this technical environment:
    -BOXIR3.1.
    -DB: SQL server 2005.
    -OS: Windows server 2003.
    When i try to create a report under Deski, with 2 objects, i get this error:
    "Exception: DBD, [ ODBC SQL Server Driver][SQL Server]Impossible
    de préparer les insctruction.state:42000"
    Note : I have tried all the tests(under the server, with administrator account.. ) but i get the same problem under Deski, but under Webi when i create the same Query nothings happen, in other words it works.
    I have copied the SQL query:
    SELECT                                                                               
    count (distinct (convert(char                                                                               
    (10),dbo.Tbld_CLI_PMSI_RSS.CLI_Donn_NoAbsEpisode)'_'convert(char                                                                 
    (10),dbo.Tbld_CLI_PMSI_RSS.CLI_Donn_NoRSS))),                                                                               
    year(( dbo.Tbld_CLI_PMSI_RSS.CLI_Date_Entree ))                                                                               
    FROM                                                                               
    dbo.Tbld_CLI_PMSI_RSS        
    *I activated the log, and i send you the 3      *
    interesting line:
    1- 2009/04/23 16:23:46.449|==| | | 3296|3924| |||||||||||||||BOCSHelper::DoRealCSDescribe( SELECT    count (distinct (convert(char(10),dbo.Tbld_CLI_PMSI_RSS.CLI_Donn_NoAbsEpisode)'_'convert(char(10),dbo.Tbld_CLI_PMSI_RSS.CLI_Donn_NoRSS))),    year(( dbo.Tbld_CLI_PMSI_RSS.CLI_Date_Entree ))  FROM    dbo.Tbld_CLI_PMSI_RSS   )
    2-  sqlboAsyncNet.cpp:83:void __cdecl job_thread::Describe|E| | 3296|2044| |||||||||||||||job_thread::Describe : DBD:[Microsoft][ODBC SQL Server Driver][SQL Server]Impossible de préparer les instructions.     
    Thank you for any suggestion.
    Regards,
    Aimen
    Edited by: Aimen Akriche on Apr 24, 2009 10:35 AM
    Edited by: Aimen Akriche on Apr 24, 2009 10:36 AM

    Hi Aimen,
    Following solution might be helpful in resolving the issue.
    SQL statement is case sensitive in Business Objects.
    Follow these steps:
    Test the connection in your universe and click Details.
    From Details, copy and run the path for the PRM file used by your connection which will open the relevant PRM file in Notepad.
    Modify the following parameter (or add to the PRM file if it does not exist) as follows:
    <Parameter Name="CASE_SENSITIVE">N</Parameter>
    Save the PRM file.
    Close and relaunch Designer.
    Regards,
    Sarbhjeet Kaur

  • To Restrict SQL account from accessing Sql server via SSMS

    Hi All,
    We are planning to tighten the security of our SQL Server.
    In the initial phase, we want to restrict all the SQL accounts(except sa) from accessing SQL Server via SSMS
    Since the SQL passwords are used in the connection strings(plain text) of our .NET Applications, developers are able to see it and they are accessing SQL server through SSMS with the credentials in the connection string.
    The requirement is, SQL accounts should only be accessing the databases through .NET applications and not through any other applications like SSMS, SQLCMD...etc
    1) We tried "Logon Trigger", but later we came to know that there is security breach in it.
    2) Application Roles - Password is plain text, again back to square one.
    We are looking for an alternate. Please share some ideas.
    Thanks & Regards,
    K.P.Senthil Kumar

    The basic presumption here is that there is on way you can tie a connection to an application as such. There is app_name(), but since this is passed from the application, the application can call itself whatever you want.
    As long as it is only a matter of keeping business users out, you can solve the issue with some three-tiered solution. Either by having a true middle layer, or just having a web server, or the application running on Terminal Server or Citrix.
    But you want to keep the developers out who work with the code. That makes it difficult to lock them out of the middle layer.
    Then again, you say "our SQL Server" is that singular? Don't you have more than one SQL Server? One for developement, one for test and one for production? If you only want to keep the devs out from development, you have different usernames
    and password for different environments, and they are read from config files. The config files for production should be well-protected.
    By the way, only permitting sa from logging in from SSMS is bad idea. Rather, you should disable sa, and everyone should log in with their individual Windows account. And those who should perform system-administration tasks should be member of sysadmin.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Migrating from MS SQL Server 2005 database to Oracle 10g

    Hello,
    I wanted the full procedure or steps to Migrate the MS SQL Server 2005 database to Oracle 10g. Is there a known procedure to do this or is there a tool which is used?
    I have not done migration of database from MS SQL Server to Oracle. Any help is appreciated. Thanks a lot for the time.
    Regards,
    RPS

    Wrong forum, go to the database forum!
    cu
    Andreas

  • How to restore a database backup taken from a SQL Server 2012 instance to SQL Server 2014

    I am trying to restore a database backup taken from a SQL Server 2012 instance to my new SQL Server 2014 instance.  When I add the .bak through the Mgmt studio UI, it does not seem to find a backup set in the file so I cannot proceed (does not give
    me any errors though either.  I tried restoring through TSQL command but only got a database restore terminating abnormally error with no other details.  How can I restore this database to SQL 2014?

    Hello,
    Please examine SQL Server Error Log and share with us any error you can find. The following article may locate the log:
    http://msdn.microsoft.com/en-us/library/ms187109.aspx
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Copying more tables from a SQL Server db to another one - SSIS 2012

    Hi,
    in order to copy data of more tables (more an hundred) from a SQL Server db to a SQL Server destination db I'd like to use the Transfer SQL Server objects task, but the source tables belonged to the dbo schema and the destination schema is a different
    one.
    It seems that this task doesn't provide a such option.
    Any suggests to me, please?
    Thanks

    http://www.experts-exchange.com/Database/MS-SQL-Server/Q_26533111.html
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to integrate from MS SQL SERVER 2005 and Flatfile to Oracle 10g.

    Hi
    I am new to ODI. I am trying to load sample data from MS SQL Server 2005 and Flatfile to Oracle 10g.
    1. I have created three models.
    1-1. SQL2005 (SRC_CUSTOMER table)
    1-2. Flatfile (SRC_AGE_GROUP.txt & SRC_SALES_PERSON.txt)
    1-3. Oracle 10g (TRG_CUSTOMER table)
    You may know I got those environments from the ODI DEMO environment.
    2. I could able to reverse the tables also.
    3. I have created an interface which contains source table (from MSSQL 2005), Flatfile and target table from ORACLE model.
    4. I have imported the knowledge modules. But I am confusing in selecting the knowledge modules to source and target tables.
    I've selected LKM File to SQL for flatfile model.
    I've also selected LKM SQL to SQL for MSSQL 2005 model and IKM Oracle Incremental Update for the target table (ORACLE).
    I've also implemented the interface that I created. It worked without errors. But there is no data in target table which is TRG_CUSTOMER.
    I really would like to know what happened and what the problems are.
    You can email me [email protected]
    Thanks in advance
    Jason Lee

    what did give for SRC_AGE_GROUP SRC_CUSTOMER join condition
    if it is
    (SRC_CUSTOMER.AGE=SRC_AGE_GROUP.AGE_MIN) AND SRC_CUSTOMER.AGE=SRC_AGE_GROUP.AGE_MAX
    give it as
    (SRC_CUSTOMER.AGE>SRC_AGE_GROUP.AGE_MIN) AND SRC_CUSTOMER.AGE<SRC_AGE_GROUP.AGE_MAX

  • How to replicate data from MS SQL Server  to Oracle

    Hi,
    Can someone please help me on how to replicate data from MS SQL Server to Oracle 8i database.

    Dear,
    I'm a student.
    I do simple replication on Oracle 8.0.5 successfully. (one master site and one snapshot site). I only use the SQL*Plus and Schema Manager to do.
    But when I do advance replication (multimaster replication) I meet many problem. So I don't get the result.
    Do you show me the technology to do that ?
    Thanks !

  • I can't link to an I series (IBM AS400) server from my sql server 2014 server (64 bit) -- but yes can link on sql server 2005 (32 bit)

    I have an I series (IBM AS400) server linked "OK" to a sql 2005 sql server (32 big).  I copied the link script (but changed credentials) from the sql server 2005 link and attempted to run it in the sql server 2014 server (on win 7 64 
    bit).  There are no complaints from SSMS when I run the script, but when I try to query a table I get this error message:
    OLE DB provider "MSDASQL" for linked server "CWMPDTA" returned message "[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed".
    OLE DB provider "MSDASQL" for linked server "CWMPDTA" returned message "[IBM][System i Access ODBC Driver]Key value in connection string too long.".
    Msg 7303, Level 16, State 1, Line 11
    Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "CWMPDTA".
    Here is the script (from the sql server 2005 (32 bit)) I ran on the sql server 2014 SSMS -- is there anything I need to change?  How can I get this I series server to link to my sql server 2014 server?
    USE [master]
    GO
    /****** Object: LinkedServer [CWMPDTA] Script Date: 9/25/2014 10:39:12 AM ******/
    EXEC master.dbo.sp_addlinkedserver @server = N'CWMPDTA', @srvproduct=N'cwmpdta', @provider=N'MSDASQL', @datasrc=N'iseries2', @provstr=N'Provider=IBMDA400.DataSource.1;Password=myPwrd;Persist Security Info=True;User ID=myID;Data Source=10.0.0.51;Initial Catalog=T9S', @catalog=N'T9S'
    /* For security reasons the linked server remote logins password is changed with ######## */
    EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'CWMPDTA',@useself=N'False',@locallogin=NULL,@rmtuser=N'myID',@rmtpassword='myPwrd'
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'collation compatible', @optvalue=N'false'
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'data access', @optvalue=N'true'
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'dist', @optvalue=N'false'
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'pub', @optvalue=N'false'
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'rpc', @optvalue=N'false'
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'rpc out', @optvalue=N'false'
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'sub', @optvalue=N'false'
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'connect timeout', @optvalue=N'0'
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'collation name', @optvalue=null
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'lazy schema validation', @optvalue=N'false'
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'query timeout', @optvalue=N'0'
    GO
    EXEC master.dbo.sp_serveroption @server=N'CWMPDTA', @optname=N'use remote collation', @optvalue=N'true'
    GO
    Rich P

    Thank you for this reply.  I went to the link and selected the option for DB2s and ran the install.  Then I started up SSMS.  I copied the same script as above, and it executed successfully.  But when I try to run a query against
    a table in a database on this linked sever -- I get this error message:
    OLE DB provider "MSDASQL" for linked server "CWMPDTA" returned message "[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed".
    OLE DB provider "MSDASQL" for linked server "CWMPDTA" returned message "[IBM][System i Access ODBC Driver]Key value in connection string too long.".
    Msg 7303, Level 16, State 1, Line 8
    Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "CWMPDTA".
    Do I need to change the line containing -- @provider=N'MSDASQL',  maybe?
    this is the query I'm running:
    select TOP 10 * from CWMPDTA.T9S.CWMPDTA.INSKU
    The same exact query runs fine on the sql server 2005 linked server.  Is there something I need to configure?
    Rich P

  • Convert data into Date Format imported from MS SQL Server.

    I have imported Data from MS SQL Server. The "Date Column" received in number format like 41017.6361109954. How can i convert it into Date in Oracle SQL.
    If i import same Data in Excel and change the Column Type to Date. It changes successfully. But in Oracle, I tried To_Date function with different parameters but it didn't work.
    Edited by: XAVER on Apr 22, 2012 2:31 AM

    XAVER wrote:
    The actual date for 41017.6361109954 is 22-Apr-2012 but its showing 20-APR-2082It looks like offset is January 1, 2000:
    select timestamp '2000-01-01 00:00:00' + numtodsinterval(41017.6361109954,'day') from dual;
    20-APR-12 03.15.59.990002560 PM
    SQL> SY.

  • Data migrated from MS SQL Server 2k to Oracle8i is not the same :(

    I'm trying to help a customer here who is trying to migrate a
    table from MS SQL Server 2000 with column WORD of type varchar
    (100) to Oracle8i (8.1.7.2) using Oracle Migration Workbench
    1.4.0.1 using MS SQL Server 2000 plugin. That column has unique
    values and has a primary key enabled on it. When migrated, the
    table on Oracle will have duplicate and incorrect data as well
    as ORA-2437: cannot validate (JAVAFARM.PK_IDX_WORD) - primary
    key violated.
    The data on both tables look like this :
    ss2k value oracle value
    ========== ============
    &#8364; &#9488;
    &#8230; &#9488;
    &#8217; &#9488;
    &#8211; &#9488;
    &#402; &#9488;
    Y= &#9488;
    4 &#9488;
    &#8211;0 &#9488;
    &#8212; &#9488;
    & &#9488;
    &#8216; &#9488;
    Any idea what could be wrong or how to fix such thing?
    Thanks :)
    Fawaz.

    otn.oracle.com -> technologies -> Migration Workbench ->
    Oracle Migration Workbench Release 1.4.1.0.0 for Windows (yes
    even for 14101 beta) -> Agree to export/license conditions ->
    enter email or ignore -> Scroll down page to beta versions ->
    download omwb14101.exe (or download it piece by piece) and
    sqlserver2000.exe
    Regards,
    Jim.

  • Migrating Japanese Characters from MS SQL Server 2000 to Oracle 9i usng Jsp

    Hi ,
    I have a situation where the Japanese characters are to be migrated from MS SQL Server 2000 to Oracle 91 and then render the same using JSP.
    I followed the below approach,
    1. Extract the Japanese data from MS SQL Server and generate an XML
    2. Parse the XML and store it into Oracle 9i database which is of UTF-8 encoding.
    3. On retreiving and rendering using the Shift-JIS adds few junk characters additionally.
    When I try to copy paste the Japanese contents from XML to a text file, it is working fine.
    Could some one help me in resolving this issue?
    It is very urgent, and any help would be greatly appreciated.

    There is documentation in the reference guide sent with the workbench, there is this discussion forum, the support web page (which includes tech notes and FAQ's), and the company specific procedural language documentation.
    There is also an older document for use with the old sybase toolkits which may be obscelete, and there are some internal documents which were for internal consumption.
    Turloch
    Oracle Migration Workbench Team

Maybe you are looking for

  • Ipod touch is no longer compatible with Gear Box??

    I turned on Gear Box with Ipod touch attached and having been avoiding update notifications, decided to go ahead and let it update ios 5 thingy.  Once updated via my laptop connection I put it back in the slot on the gear box and now I get a message

  • How do I delete a digital signature in adobe acrobat 8 as it has been spelt incorrectly?

    A digital signature was created in adobe acrobat 8 professional but has been spelt incorrectly - how can I delete or edit it?

  • Imported PO report with prices ,clearing charges..etc?

    Hi gurus Can anybody give som input for my query related to Imported Purchase order report with below details Purchase Voucher      Party Name      Description      Basic Doc No.      Freight Doc No      Customs Doc No.      Basic + Pkg      Freight 

  • Substitution in ABT1n transaction

    In ABT1N transaction code, systen is picking GL codes from AO90 accoun determination. We want to substitute one the GL code by our own GL code. I  have written this substitution in FI module and is is not working. My question is ,where this substitut

  • Printing in the real world

    Trying to print from my iPad. All other computers in the house are PC-based. Printer is an Ethernet connected and addressable HP multifunction printer. So how do I print from my iPad to a network printer? It takes less than a minute to enable this pr