mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add h2 support
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>0.2.4-SNAPSHOT</version>
|
||||
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<name>druid</name>
|
||||
<description>An JDBC datasource implementation.</description>
|
||||
@@ -56,7 +56,7 @@
|
||||
<email>szujobs@hotmail.com</email>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
|
||||
<scm>
|
||||
<url>https://wenshao@github.com/AlibabaTech/druid.git</url>
|
||||
<connection>scm:git:https://wenshao@github.com/AlibabaTech/druid.git</connection>
|
||||
@@ -66,7 +66,7 @@
|
||||
<name>Alibaba Group</name>
|
||||
<url>http://code.alibabatech.com/</url>
|
||||
</organization>
|
||||
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache 2</name>
|
||||
@@ -75,7 +75,7 @@
|
||||
<comments>A business-friendly OSS license</comments>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
|
||||
<issueManagement>
|
||||
<system>Jira</system>
|
||||
<url>http://code.alibabatech.com/jira/browse/DRUID</url>
|
||||
@@ -126,17 +126,17 @@
|
||||
<attach>true</attach>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadoc</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<execution>
|
||||
<id>attach-javadoc</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<show>public</show>
|
||||
<charset>UTF-8</charset>
|
||||
@@ -147,7 +147,7 @@
|
||||
</links>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<executions>
|
||||
@@ -160,7 +160,7 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -251,14 +251,8 @@
|
||||
<version>9.1-901-1.jdbc4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>com.oracle</groupId>
|
||||
<artifactId>ojdbc5</artifactId>
|
||||
<version>11.2.0.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
-->
|
||||
<!-- <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc5</artifactId>
|
||||
<version>11.2.0.3</version> <scope>provided</scope> </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.oracle</groupId>
|
||||
@@ -317,7 +311,7 @@
|
||||
<version>0.7.1-rc2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>proxool</groupId>
|
||||
<artifactId>proxool</artifactId>
|
||||
@@ -330,19 +324,26 @@
|
||||
<version>0.9.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>c3p0</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
<version>0.9.1.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.ibatis</groupId>
|
||||
<artifactId>ibatis-sqlmap</artifactId>
|
||||
<version>2.3.4.726</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.3.167</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -102,7 +102,6 @@ public class MySqlMockExecuteHandlerImpl implements MockExecuteHandler {
|
||||
return rs;
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public ResultSet executeQueryFromDual(MockStatement statement, SQLSelectQueryBlock query) throws SQLException {
|
||||
MockResultSet rs = new MockResultSet(statement);
|
||||
MockResultSetMetaData metaData = rs.getMockMetaData();
|
||||
|
||||
@@ -62,10 +62,12 @@ public final class JdbcUtils {
|
||||
public static final String MYSQL = "mysql";
|
||||
|
||||
public static final String DERBY = "derby";
|
||||
|
||||
|
||||
public static final String HBASE = "hbase";
|
||||
|
||||
public static final String HIVE = "hive";
|
||||
|
||||
public static final String HIVE = "hive";
|
||||
|
||||
public static final String H2 = "h2";
|
||||
|
||||
private final static Log LOG = LogFactory.getLog(JdbcUtils.class);
|
||||
|
||||
@@ -445,7 +447,7 @@ public final class JdbcUtils {
|
||||
} else if (rawUrl.startsWith("jdbc:ingres:")) {
|
||||
return "ingres";
|
||||
} else if (rawUrl.startsWith("jdbc:h2:")) {
|
||||
return "h2";
|
||||
return H2;
|
||||
} else if (rawUrl.startsWith("jdbc:mckoi:")) {
|
||||
return "mckoi";
|
||||
} else if (rawUrl.startsWith("jdbc:cloudscape:")) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Case0 extends TestCase {
|
||||
private String user;
|
||||
private String password;
|
||||
private String driverClass;
|
||||
private int initialSize = 10;
|
||||
private int initialSize = 1;
|
||||
private int minIdle = 3;
|
||||
private int maxIdle = 8;
|
||||
private int maxActive = 8;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.alibaba.druid.bvt.pool;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
public class TestH2 extends TestCase {
|
||||
|
||||
private DruidDataSource dataSource;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:h2:mem:");
|
||||
dataSource.setPoolPreparedStatements(true);
|
||||
dataSource.setMaxOpenPreparedStatements(10);
|
||||
|
||||
dataSource.init();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
JdbcUtils.close(dataSource);
|
||||
}
|
||||
|
||||
public void test_h2() throws Exception {
|
||||
Assert.assertSame(JdbcUtils.H2, dataSource.getDbType());
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement("SELECT ?");
|
||||
|
||||
stmt.setString(1, "xxxx");
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
|
||||
rs.next();
|
||||
Assert.assertEquals("xxxx", rs.getString(1));
|
||||
|
||||
rs.close();
|
||||
|
||||
stmt.close();
|
||||
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import com.alibaba.druid.sql.dialect.oracle.visitor.OracleOutputVisitor;
|
||||
public class CallTest extends TestCase {
|
||||
|
||||
public void test_select() throws Exception {
|
||||
String sql = "CALL test(1)";
|
||||
String sql = "call dbms_session.set_identifier('nfs_special_syncview')";
|
||||
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
List<SQLStatement> statementList = parser.parseStatementList();
|
||||
|
||||
Reference in New Issue
Block a user