Skip to content

Commit

Permalink
[meta]改进AbstractDevotedDBMetaResolver数据库兼容问题,DBCP升级至2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
datageartech committed Mar 31, 2020
1 parent 3b1f56a commit 5834cfd
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 95 deletions.
4 changes: 2 additions & 2 deletions datagear-connection/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>${DBCP.version}</version>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp.ConnectionFactory;
import org.apache.commons.dbcp.DriverConnectionFactory;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.dbcp2.ConnectionFactory;
import org.apache.commons.dbcp2.DriverConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -640,29 +640,33 @@ protected static class DriverBasicDataSource extends BasicDataSource
{
private Driver driver;

private Properties connectionProperties;

public DriverBasicDataSource(Driver driver, String url, Properties properties)
{
super();
this.driver = driver;
super.setDriverClassName(driver.getClass().getName());
super.setUrl(url);
super.connectionProperties = properties;
this.connectionProperties = properties;
}

protected Driver getDriver()
@Override
public Driver getDriver()
{
return driver;
}

protected void setDriver(Driver driver)
@Override
public void setDriver(Driver driver)
{
this.driver = driver;
}

@Override
protected ConnectionFactory createConnectionFactory() throws SQLException
{
return new DriverConnectionFactory(driver, url, connectionProperties);
return new DriverConnectionFactory(driver, getUrl(), this.connectionProperties);
}
}
}
21 changes: 11 additions & 10 deletions datagear-meta/src/main/java/org/datagear/meta/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,29 +144,30 @@ public Column[] getColumns(String... names)
return columns;
}

@Override
public String toString()
{
return getClass().getSimpleName() + " [name=" + getName() + ", type=" + getType() + ", comment=" + getComment()
+ ", columns=" + Arrays.toString(columns) + ", primaryKey=" + primaryKey + ", uniqueKeys="
+ Arrays.toString(uniqueKeys) + ", importKeys=" + Arrays.toString(importKeys) + "]";
}

/**
* 获取所有二进制列。
*
* @return 返回空数组表示没有。
*/
public Column[] getBinaryColumns()
public static Column[] getBinaryColumns(Table table)
{
List<Column> bcs = new ArrayList<>(1);

for (Column column : this.columns)
Column[] columns = table.getColumns();
for (Column column : columns)
{
if (JdbcUtil.isBinaryType(column.getType()))
bcs.add(column);
}

return bcs.toArray(new Column[bcs.size()]);
}

@Override
public String toString()
{
return getClass().getSimpleName() + " [name=" + getName() + ", type=" + getType() + ", comment=" + getComment()
+ ", columns=" + Arrays.toString(columns) + ", primaryKey=" + primaryKey + ", uniqueKeys="
+ Arrays.toString(uniqueKeys) + ", importKeys=" + Arrays.toString(importKeys) + "]";
}
}
Loading

0 comments on commit 5834cfd

Please sign in to comment.