From 760e361b3f062c0b566c45a3c24a88904d343d13 Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 12 Jun 2003 16:09:27 +0000 Subject: [PATCH] add getDBConnection(). --- src/helma/scripting/rhino/GlobalObject.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/helma/scripting/rhino/GlobalObject.java b/src/helma/scripting/rhino/GlobalObject.java index 8fdf1100..e8e5790e 100644 --- a/src/helma/scripting/rhino/GlobalObject.java +++ b/src/helma/scripting/rhino/GlobalObject.java @@ -48,7 +48,8 @@ public class GlobalObject extends ScriptableObject { String[] globalFuncs = { "renderSkin", "renderSkinAsString", "getProperty", "authenticate", "createSkin", "format", "encode", - "encodeXml", "encodeForm", "stripTags" + "encodeXml", "encodeForm", "stripTags", + "getDBConnection" }; defineFunctionProperties(globalFuncs, GlobalObject.class, 0); @@ -195,6 +196,17 @@ public class GlobalObject extends ScriptableObject { return new Skin(str, app); } + public DatabaseObject getDBConnection(String dbsource) throws Exception { + if (dbsource == null) + throw new RuntimeException ("Wrong number of arguments in getDBConnection(dbsource)"); + DbSource dbsrc = app.getDbSource (dbsource.toLowerCase ()); + if (dbsrc == null) + throw new RuntimeException ("DbSource "+dbsource+" does not exist"); + DatabaseObject db = new DatabaseObject (dbsrc, 0); + return db; + } + + /** * *