In Oracle RDBMS you can compile a java source:
CREATE AND COMPILE JAVA SOURCE NAMED helloworld_app_source AS
public class helloworld_app {
public static String helloworld_func()
{
return "Hello, world!";
}
}
Then you can wrap it in an Oracle function:
CREATE FUNCTION helloworld_func RETURN VARCHAR2
AS LANGUAGE JAVA NAME 'helloworld_app.helloworld_func() return java.lang.String';
/
Then you can just call it in an normal SQL statement (as per any other function):
SELECT helloworld_func() FROM DUAL;
The Java function will run on the server but the query can be invoked from any SQL client connected to the server and will return the output to that client.