Executing JavaScript within the Database

October 1, 2014

Tags: #database #javaone #oracle #nashorn #javascript #java

Today I attended a pretty strange talk at JavaOne: Running JavaScript in the database!

WTF?

Thanks to Oracle, it's possible since more than seven or eight years, to execute Java classes within the Oracle Database. So far, so good. Sounds a bit strange, but perhaps there are use cases. I myself can't imagine an use case where you really need this approach. But this is a different story.

Since the development of Nashorn JavaScript engine, it's possible to execute JavaScript commands, files, etc. directly from your Java code. Pretty nice, and there _are_ use cases I can imagine this approach.

Now somebody had the strange idea to execute JavaScript commands from Nashorn, running in the JVM, running in the Oracle Database... I. Don't. Have. Any. Words. For. That!
(for the technicans of you: Oracle Database does only support Java 7 so far, as Nashorn is available since Java 8, you need the standalone nashorn.jar library additionally)

If you know me and my blog, you know that I really like non-UI JavaScript solutions, like server-side scripting or JavaScript for microcontrollers with Espruino.
BUT WHY THE HECK I SHOULD USE JAVASCRIPT WITHIN MY DATABASE???
I really don't have any idea about that. And, additionally, I'm a bit scared of doing this... I'm a bit scared of upcoming solutions using this approach...

(ok, it was just a proof-of-concept within this talk, but I'm still scared!)

« My talk at JavaOne Oracle announces Avatar 2.0 at JavaOne »