Home Forums Programming CLR Integration and Programming. SQL 2008 R2 - Need to create a CLR assembly that calls a Java function and implement as a UDF RE: SQL 2008 R2 - Need to create a CLR assembly that calls a Java function and implement as a UDF

  • Trying to go at it using code that actually reference the Java assembly within .NET is going to force you into making your assembly "unsafe". You may not want to pursue the direct approach and wrap your Java code using a few methods which might make accessing it more palatable.

    Two options spring to mind:

    1. the first option is closest to what you're envisioning. The trick would be to create a .NET assembly that accesses the java assembly using REST. REST is essentially a web service call, which puts the execution context of the java code outside of SQL Server itself, allowing you to preserve the TRUSTWORTHY access (i.e. the SQLCLR procedure can't be used to damage SQL Server, etc...). Obviously you'd have to set up your java assembly to be callable via REST (usually wrapping it within a WAR file and posting it to Apache, etc..)

    A few primers on this:

    http://blogs.msdn.com/b/sqllive/archive/2008/06/18/accessing-rest-based-web-services-using-sql-clr.aspx

    http://sqlsunday.com/2013/03/03/web-requests-using-clr-proc/[/url]

    2. Use SQL broker

    SQL Service Broker can be wired into using JMS (Java messaging). This one's not for the faint of heart, but it can be very performant if you're comfortable with SSB. I've seen it in action, but am not in a position to walk you through all of the steps.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?