Search in sources :

Example 1 with ParamSyntax

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);
}
Also used : ClassDefinitionImpl(lucee.transformer.library.ClassDefinitionImpl) StructImpl(lucee.runtime.type.StructImpl) DataSourceImpl(lucee.runtime.db.DataSourceImpl) ClassDefinition(lucee.runtime.db.ClassDefinition) ParamSyntax(lucee.runtime.db.ParamSyntax) PageException(lucee.runtime.exp.PageException) SecurityException(lucee.runtime.exp.SecurityException) IOException(java.io.IOException) DeprecatedException(lucee.runtime.exp.DeprecatedException) BundleException(org.osgi.framework.BundleException) MalformedURLException(java.net.MalformedURLException) SMTPException(lucee.runtime.net.mail.SMTPException) ApplicationException(lucee.runtime.exp.ApplicationException) Struct(lucee.runtime.type.Struct) DataSource(lucee.runtime.db.DataSource)

Aggregations

IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 ClassDefinition (lucee.runtime.db.ClassDefinition)1 DataSource (lucee.runtime.db.DataSource)1 DataSourceImpl (lucee.runtime.db.DataSourceImpl)1 ParamSyntax (lucee.runtime.db.ParamSyntax)1 ApplicationException (lucee.runtime.exp.ApplicationException)1 DeprecatedException (lucee.runtime.exp.DeprecatedException)1 PageException (lucee.runtime.exp.PageException)1 SecurityException (lucee.runtime.exp.SecurityException)1 SMTPException (lucee.runtime.net.mail.SMTPException)1 Struct (lucee.runtime.type.Struct)1 StructImpl (lucee.runtime.type.StructImpl)1 ClassDefinitionImpl (lucee.transformer.library.ClassDefinitionImpl)1 BundleException (org.osgi.framework.BundleException)1