This commit is contained in:
2019-04-11 23:04:13 +08:00
parent 6e7388ddf4
commit 14795814e3
24 changed files with 384 additions and 66 deletions

View File

@@ -1,5 +1,7 @@
package net.tccn.dbq;
import net.tccn.dbq.table.Column;
/**
* @author: liangxianyou at 2018/10/17 17:24.
*/
@@ -11,6 +13,7 @@ public class Field {
private String inType;
private String inExt;
public Field() {}
//============== getter/setter =============
public String getName() {
@@ -92,6 +95,15 @@ public class Field {
return InType.SELECT_EXT.name.equalsIgnoreCase(inType);
}
public static Field toAs(Column column) {
Field _bean = new Field();
_bean.setName(column.getField());
_bean.setType(column.getType());
_bean.setLabel(column.getComment());
return _bean;
}
@Override
public boolean equals(Object name) {
return (this.name == null && name == null) || this.name.equals(name);

View File

@@ -125,7 +125,7 @@ public class JdbcService {
connection.setCatalog(table.getCatalog());
}
String tableDdl = table.getTableDdl();
String tableDdl = ""; // table.getTableDdl();
System.out.println(tableDdl);
try (PreparedStatement ps = connection.prepareStatement(tableDdl)) {
return ps.execute();

View File

@@ -137,9 +137,6 @@ public class DbSourceMysql implements DbSource {
System.out.println("创建新的连接:" + x);
} else {
conn = queue.take();
if (conn != null) {
System.out.println("获取已有连接" + conn);
}
}
} catch (SQLException | InterruptedException e) {
if (e instanceof InterruptedException) {
@@ -167,7 +164,7 @@ public class DbSourceMysql implements DbSource {
if (connection != null) {
queue.put(connection);
conns.put(accountKey, queue);
System.out.println("还回连接:" + connection);
//System.out.println("还回连接:" + connection);
}
} catch (InterruptedException e) {
e.printStackTrace();

View File

@@ -56,5 +56,4 @@ public class Column {
public void setNull(String notNull) {
this.notNull = "NO".equalsIgnoreCase(notNull) ? true : false;
}
}

View File

@@ -1,6 +1,7 @@
package net.tccn.dbq.table;
import java.util.ArrayList;
import java.util.List;
/**
@@ -11,8 +12,9 @@ public class Table {
private String catalog; //库名称
private String name; //表名称
private String comment; //表备注
private List<Column> columns; //表的字段列
private List<Column> columns = new ArrayList<>(); //表的字段列
public Table() {}
public Table(String name, String comment) {
this.name = name;
this.comment = comment;
@@ -55,7 +57,7 @@ public class Table {
//------------------------------
//Dev
public String getTableDdl() {
public String _getTableDdl() {
StringBuilder buf = new StringBuilder();
buf.append("CREATE TABLE " + name + "(");