add getDBConnection().

This commit is contained in:
hns 2003-06-12 16:09:27 +00:00
parent 1515cc96af
commit 760e361b3f

View file

@ -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;
}
/**
*
*