use of lucee.runtime.db.ParamSyntax in project Lucee by lucee.
the class Admin method doUpdateDatasource.
/**
* @throws PageException
*/
private void doUpdateDatasource() throws PageException {
int allow = (getBoolV("allowed_select", false) ? DataSource.ALLOW_SELECT : 0) + (getBoolV("allowed_insert", false) ? DataSource.ALLOW_INSERT : 0) + (getBoolV("allowed_update", false) ? DataSource.ALLOW_UPDATE : 0) + (getBoolV("allowed_delete", false) ? DataSource.ALLOW_DELETE : 0) + (getBoolV("allowed_alter", false) ? DataSource.ALLOW_ALTER : 0) + (getBoolV("allowed_drop", false) ? DataSource.ALLOW_DROP : 0) + (getBoolV("allowed_revoke", false) ? DataSource.ALLOW_REVOKE : 0) + (getBoolV("allowed_grant", false) ? DataSource.ALLOW_GRANT : 0) + (getBoolV("allowed_create", false) ? DataSource.ALLOW_CREATE : 0);
if (allow == 0)
allow = DataSource.ALLOW_ALL;
String cn = getString("admin", action, "classname");
if ("com.microsoft.jdbc.sqlserver.SQLServerDriver".equals(cn)) {
cn = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
}
ClassDefinition cd = new ClassDefinitionImpl(cn, getString("bundleName", null), getString("bundleVersion", null), config.getIdentification());
// customParameterSyntax
Struct sct = getStruct("customParameterSyntax", null);
ParamSyntax ps = (sct != null && sct.containsKey("delimiter") && sct.containsKey("separator")) ? ParamSyntax.toParamSyntax(sct) : ParamSyntax.DEFAULT;
//
boolean literalTimestampWithTSOffset = getBoolV("literalTimestampWithTSOffset", false);
boolean alwaysSetTimeout = getBoolV("alwaysSetTimeout", false);
String dsn = getString("admin", action, "dsn");
String name = getString("admin", action, "name");
String newName = getString("admin", action, "newName");
String username = getString("admin", action, "dbusername");
String password = getString("admin", action, "dbpassword");
String host = getString("host", "");
String timezone = getString("timezone", "");
String database = getString("database", "");
int port = getInt("port", -1);
int connLimit = getInt("connectionLimit", -1);
int connTimeout = getInt("connectionTimeout", -1);
long metaCacheTimeout = getLong("metaCacheTimeout", 60000);
boolean blob = getBoolV("blob", false);
boolean clob = getBoolV("clob", false);
boolean validate = getBoolV("validate", false);
boolean storage = getBoolV("storage", false);
boolean verify = getBoolV("verify", true);
Struct custom = getStruct("custom", new StructImpl());
String dbdriver = getString("dbdriver", "");
// config.getDatasourceConnectionPool().remove(name);
DataSource ds = null;
try {
ds = new DataSourceImpl(config, null, name, cd, host, dsn, database, port, username, password, connLimit, connTimeout, metaCacheTimeout, blob, clob, allow, custom, false, validate, storage, null, dbdriver, ps, literalTimestampWithTSOffset, alwaysSetTimeout, config.getLog("application"));
} catch (Exception e) {
throw Caster.toPageException(e);
}
if (verify)
_doVerifyDatasource(ds, username, password);
// print.out("limit:"+connLimit);
admin.updateDataSource(name, newName, cd, dsn, username, password, host, database, port, connLimit, connTimeout, metaCacheTimeout, blob, clob, allow, validate, storage, timezone, custom, dbdriver, ps, literalTimestampWithTSOffset, alwaysSetTimeout);
store();
adminSync.broadcast(attributes, config);
}
Aggregations