Merge pull request #1106 from wenshao/master

changed DruidDataSource discardConnectiion filling logic
This commit is contained in:
wenshao
2016-03-11 11:47:09 +08:00
5 changed files with 21 additions and 7 deletions
@@ -931,6 +931,10 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
if (inited && value > this.maxActive) {
throw new IllegalArgumentException("minIdle greater than maxActive, " + maxActive + " < " + this.minIdle);
}
if (minIdle < 0) {
throw new IllegalArgumentException("minIdle must > 0");
}
this.minIdle = value;
}
@@ -1059,7 +1059,7 @@ public class DruidDataSource extends DruidAbstractDataSource
activeCount--;
discardCount++;
if (activeCount <= 0) {
if (activeCount <= minIdle) {
emptySignal();
}
} finally {
@@ -537,7 +537,7 @@ public class MySqlLexer extends Lexer {
if (c <= identifierFlags.length) {
return identifierFlags[c];
}
return false;
return c != ' ' && c != ',';
}
public void scanNumber() {
@@ -15,10 +15,17 @@ public class DruidDataSourceConverterTest extends TestCase {
private DruidDataSource dataSource;
protected void setUp() throws Exception {
String osName = System.getProperty("os.name");
String root = DruidDataSourceConverterTest.class
.getResource("/com/alibaba/druid/pool/simplejndi/").toString();
if (root.startsWith("file:/"))
if (root.startsWith("file:/")) {
root = root.substring("file://".length() - 1);
}
if (osName.toLowerCase().indexOf("win") == -1) {
root = "/" + root;
}
Properties props = new Properties();
props.put("org.osjava.sj.root", root);
props.put("java.naming.factory.initial",
@@ -2,11 +2,12 @@ package com.alibaba.druid.bvt.sql.schemaStat;
import org.junit.Assert;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser;
import com.alibaba.druid.sql.dialect.odps.visitor.OdpsSchemaStatVisitor;
import com.alibaba.druid.sql.parser.SQLParserUtils;
import com.alibaba.druid.sql.parser.SQLStatementParser;
import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
import com.alibaba.druid.util.JdbcConstants;
import junit.framework.TestCase;
@@ -17,10 +18,12 @@ public class SchemaStatTest extends TestCase {
+ " from alisec_app.adl_tb_wing_rubbish_laidian_new_reason_realname_fdt "
+ " order by 来电日期 desc limit 30;";
SQLStatementParser parser = new OdpsStatementParser(sql);
String dbType = JdbcConstants.ODPS;
SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType);
SQLStatement stmt = parser.parseStatementList().get(0);
SchemaStatVisitor statVisitor = new OdpsSchemaStatVisitor();
SchemaStatVisitor statVisitor = SQLUtils.createSchemaStatVisitor(dbType);
stmt.accept(statVisitor);
System.out.println(statVisitor.getColumns());