Calling java classes

  • Hi.

    Is there a way in SQL Server 2000 to call java functions (e.g. GZIP), as you do with Oracle where you can call a java class that is saved as a package? Or does all code have to be native to SQL Server?

    Regards,

    Dave

  • don't know if it's any use in your case but xp_cmdShell allows you to execute shell commands, as you would in command prompt.

    Pete

  • The short answer is no. It could be possible via extended stored procedures, which you can write in C, then use JNI, but this would be a pain and would not perform well.

    On SQL Server 2005 you could do more (generate IL code from your java app, dump that into the database, ...), but not on SQL Server 2000.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • There is no way in SQL Server 2000 exactly like Oracle's integration with Java. Starting with SQL Server 2005 you have CLR integration where you can run stored procedures or triggers which can execute classes written in a .NET language - similar to Oracle-Java integration. If you want to execute java code in SQL 2000 as part of a T-SQL batch, one way to do it is to use the extended stored procedure master..xp_cmdshell. This executes any external shell command and returns the exit code. Example: you can do something like:

    declare @rtn int

    exec @rtn = master..xp_cmdshell "java MyClass"

    print 'Exit code = ' + @rtn.

    Alternatively, if you dont require it as part of your T-SQL batch, you can explore DTS which has a Execute Process task that can be used to execute external commands. You can develop a DTS package and schedule it as a SQL Server Agent job.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply