diff --git a/src/org/redkale/source/DataDefaultSource.java b/src/org/redkale/source/DataDefaultSource.java index dcd2bcd51..dde52bf11 100644 --- a/src/org/redkale/source/DataDefaultSource.java +++ b/src/org/redkale/source/DataDefaultSource.java @@ -32,7 +32,11 @@ public final class DataDefaultSource implements DataSource, Function fullloader = (t) -> querySheet(false, false, t, null, null, (FilterNode) null).list(true); public DataDefaultSource() throws IOException { @@ -120,15 +120,6 @@ public final class DataDefaultSource implements DataSource, Function 0"); - this.props.setProperty("notcontain-sql-template", "INSTR(${keystr}, ${column}) = 0"); - } else if (this.readPool.isSqlserver()) { - this.props.setProperty("contain-sql-template", "CHARINDEX(${column}, ${keystr}) > 0"); - this.props.setProperty("notcontain-sql-template", "CHARINDEX(${column}, ${keystr}) = 0"); - } - this.props.putAll(readprop); this.cacheForbidden = "NONE".equalsIgnoreCase(readprop.getProperty("shared-cache-mode")); } @@ -137,15 +128,6 @@ public final class DataDefaultSource implements DataSource, Function 0"); - this.props.setProperty("notcontain-sql-template", "INSTR(${keystr}, ${column}) = 0"); - } else if (this.readPool.isSqlserver()) { - this.props.setProperty("contain-sql-template", "CHARINDEX(${column}, ${keystr}) > 0"); - this.props.setProperty("notcontain-sql-template", "CHARINDEX(${column}, ${keystr}) = 0"); - } - this.props.putAll(readprop); this.cacheForbidden = "NONE".equalsIgnoreCase(readprop.getProperty("shared-cache-mode")); } @@ -306,7 +288,7 @@ public final class DataDefaultSource implements DataSource, Function EntityInfo loadEntityInfo(Class clazz) { - return EntityInfo.load(clazz, this.nodeid, this.cacheForbidden, this.props, fullloader); + return EntityInfo.load(clazz, this.nodeid, this.cacheForbidden, this.readPool.props, fullloader); } /** @@ -610,7 +592,7 @@ public final class DataDefaultSource implements DataSource, Function joinTabalis = node.getJoinTabalis(); CharSequence join = node.createSQLJoin(this, joinTabalis, info); CharSequence where = node.createSQLExpress(info, joinTabalis); - String sql = "DELETE " + (mysql ? "a" : "") + " FROM " + info.getTable() + " a" + (join == null ? "" : join) + ((where == null || where.length() == 0) ? "" : (" WHERE " + where)); + String sql = "DELETE " + (this.readPool.isMysql() ? "a" : "") + " FROM " + info.getTable() + " a" + (join == null ? "" : join) + ((where == null || where.length() == 0) ? "" : (" WHERE " + where)); if (debug.get()) logger.finest(info.getType().getSimpleName() + " delete sql=" + sql); final Statement stmt = conn.createStatement(); stmt.execute(sql); diff --git a/src/org/redkale/source/JDBCPoolSource.java b/src/org/redkale/source/JDBCPoolSource.java index e97a09fa5..cabd2815a 100644 --- a/src/org/redkale/source/JDBCPoolSource.java +++ b/src/org/redkale/source/JDBCPoolSource.java @@ -55,14 +55,17 @@ public class JDBCPoolSource { private String password; + final Properties props; + public JDBCPoolSource(DataDefaultSource source, String stype, Properties prop) { this.dataSource = source; this.stype = stype; + this.props = prop; this.source = createDataSource(prop); this.url = prop.getProperty(JDBC_URL); this.user = prop.getProperty(JDBC_USER); this.password = prop.getProperty(JDBC_PWD); - this.max = Integer.decode(prop.getProperty(JDBC_CONNECTIONMAX, "" + Runtime.getRuntime().availableProcessors() * 16)); + this.max = Integer.decode(prop.getProperty(JDBC_CONNECTIONSMAX, "" + Runtime.getRuntime().availableProcessors() * 16)); this.queue = new ArrayBlockingQueue<>(this.max); this.listener = new ConnectionEventListener() { @@ -79,6 +82,14 @@ public class JDBCPoolSource { dataSource.logger.log(Level.WARNING, "connectionErronOccurred [" + event.getSQLException().getSQLState() + "]", event.getSQLException()); } }; + if (this.isOracle()) { + this.props.setProperty(JDBC_CONTAIN_SQLTEMPLATE, "INSTR(${keystr}, ${column}) > 0"); + this.props.setProperty(JDBC_NOTCONTAIN_SQLTEMPLATE, "INSTR(${keystr}, ${column}) = 0"); + } else if (this.isSqlserver()) { + this.props.setProperty(JDBC_CONTAIN_SQLTEMPLATE, "CHARINDEX(${column}, ${keystr}) > 0"); + this.props.setProperty(JDBC_NOTCONTAIN_SQLTEMPLATE, "CHARINDEX(${column}, ${keystr}) = 0"); + } + try { this.watch(); } catch (Exception e) { @@ -86,18 +97,18 @@ public class JDBCPoolSource { } } - public boolean isMysql() { + final boolean isMysql() { return source != null && source.getClass().getName().contains(".mysql."); } - public boolean isOracle() { + final boolean isOracle() { return source != null && source.getClass().getName().contains("oracle."); } - public boolean isSqlserver() { + final boolean isSqlserver() { return source != null && source.getClass().getName().contains(".sqlserver."); } - + private void watch() throws IOException { if (dataSource.conf == null || dataSource.name == null) return; final String file = dataSource.conf.getFile();