Skip to content

Commit a3f5cfd

Browse files
author
牛志欢
committed
子项目
1 parent 6472500 commit a3f5cfd

File tree

18 files changed

+164
-60
lines changed

18 files changed

+164
-60
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.nzh;
2+
3+
/**
4+
* Hello world!
5+
*
6+
*/
7+
public class App
8+
{
9+
public static void main( String[] args )
10+
{
11+
System.out.println( "Hello World!" );
12+
}
13+
}

src/main/java/com/nzh/db/QueryDb.java renamed to mybatis-tool-db/src/main/java/com/nzh/db/QueryDb.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.nzh.db;
22

3-
import com.nzh.model.Schema;
3+
4+
import com.nzh.db.model.Schema;
45

56
import java.sql.*;
67

src/main/java/com/nzh/model/Column.java renamed to mybatis-tool-db/src/main/java/com/nzh/db/model/Column.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.nzh.model;
1+
package com.nzh.db.model;
22

33
/**
44
* @author zhihuan.niu on 2016/9/13.
@@ -10,8 +10,10 @@ public class Column {
1010
private String comments;
1111
//类型
1212
private String type;
13-
//主外健
13+
//约束类型
1414
private String constraintType;
15+
//是否可空
16+
private boolean isNullAble;
1517
public String getName() {
1618
return name;
1719
}
@@ -43,4 +45,12 @@ public String getConstraintType() {
4345
public void setConstraintType(String constraintType) {
4446
this.constraintType = constraintType;
4547
}
48+
49+
public boolean isNullAble() {
50+
return isNullAble;
51+
}
52+
53+
public void setIsNullAble(boolean isNullAble) {
54+
this.isNullAble = isNullAble;
55+
}
4656
}

src/main/java/com/nzh/model/Schema.java renamed to mybatis-tool-db/src/main/java/com/nzh/db/model/Schema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.nzh.model;
1+
package com.nzh.db.model;
22

33
import java.util.ArrayList;
44
import java.util.List;

src/main/java/com/nzh/model/Table.java renamed to mybatis-tool-db/src/main/java/com/nzh/db/model/Table.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.nzh.model;
1+
package com.nzh.db.model;
22

33
import java.util.List;
44

src/main/java/com/nzh/db/IColumnService.java renamed to mybatis-tool-db/src/main/java/com/nzh/db/service/IColumnService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package com.nzh.db;
1+
package com.nzh.db.service;
22

3-
import com.nzh.model.Column;
4-
import com.nzh.model.Schema;
5-
import com.nzh.model.Table;
3+
4+
import com.nzh.db.model.Column;
5+
import com.nzh.db.model.Schema;
66

77
import java.util.List;
88

src/main/java/com/nzh/db/ISchemaService.java renamed to mybatis-tool-db/src/main/java/com/nzh/db/service/ISchemaService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.nzh.db;
1+
package com.nzh.db.service;
22

3-
import com.nzh.model.Column;
4-
import com.nzh.model.Table;
3+
import com.nzh.db.model.Column;
4+
import com.nzh.db.model.Table;
55

66
import java.util.List;
77

src/main/java/com/nzh/db/ITableService.java renamed to mybatis-tool-db/src/main/java/com/nzh/db/service/ITableService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.nzh.db;
1+
package com.nzh.db.service;
22

3-
import com.nzh.model.Schema;
4-
import com.nzh.model.Table;
3+
import com.nzh.db.model.Schema;
4+
import com.nzh.db.model.Table;
55

66
import java.util.List;
77

src/main/java/com/nzh/db/impl/OracleColumnServiceImpl.java renamed to mybatis-tool-db/src/main/java/com/nzh/db/service/impl/OracleColumnServiceImpl.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
package com.nzh.db.impl;
1+
package com.nzh.db.service.impl;
22

3-
import com.nzh.db.IColumnService;
4-
import com.nzh.db.ITableService;
53
import com.nzh.db.QueryDb;
6-
import com.nzh.model.Column;
7-
import com.nzh.model.Schema;
8-
import com.nzh.model.Table;
4+
import com.nzh.db.model.Column;
5+
import com.nzh.db.model.Schema;
6+
import com.nzh.db.service.IColumnService;
97

108
import java.sql.Connection;
119
import java.sql.PreparedStatement;
@@ -47,25 +45,30 @@ protected void queryImpl(Connection con,PreparedStatement pre,ResultSet result)
4745
String DATA_TYPE=result.getString("DATA_TYPE");
4846
String NULLABLE=result.getString("NULLABLE");
4947
String constraint_type=result.getString("constraint_type");
50-
System.out.println("name:" + result.getString("name") + " comments:"
51-
+ result.getString("comments"));
48+
System.out.println("name:" +COLUMN_NAME + " comments:" + COMMENTS);
5249
Column column=new Column();
5350
column.setName(COLUMN_NAME);
5451
column.setType(DATA_TYPE);
5552
column.setComments(COMMENTS);
5653
column.setConstraintType(constraint_type);
57-
columnList.add(column);
54+
column.setIsNullAble(NULLABLE.equals("Y"));
55+
addColumn(column);
5856
}
5957
}
58+
6059
private void addColumn(Column column){
61-
for (Column column1:columnList){
62-
if(column.getName().equals(column1.getName())){
63-
if(column1.getConstraintType()!=null){
64-
//todo
60+
if(column.getConstraintType()!=null&&column.getConstraintType().equals("P")){
61+
//为主键
62+
for (Column column1:columnList){
63+
if(column.getName().equals(column1.getName())){
64+
column1.setConstraintType(column.getConstraintType());
6565
}
6666
}
67+
}else {
68+
columnList.add(column);
6769
}
6870
}
71+
6972
public List<Column> findList(Schema schema) {
7073
this.query(schema);
7174
return columnList;

src/main/java/com/nzh/db/impl/OracleSchemaServiceImpl.java renamed to mybatis-tool-db/src/main/java/com/nzh/db/service/impl/OracleSchemaServiceImpl.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
package com.nzh.db.impl;
1+
package com.nzh.db.service.impl;
22

3-
import com.nzh.db.ISchemaService;
4-
import com.nzh.model.Column;
5-
import com.nzh.model.Schema;
6-
import com.nzh.model.Table;
3+
import com.nzh.db.model.Column;
4+
import com.nzh.db.model.Schema;
5+
import com.nzh.db.model.Table;
6+
import com.nzh.db.service.ISchemaService;
77

8-
import java.sql.Connection;
9-
import java.sql.DriverManager;
10-
import java.sql.PreparedStatement;
11-
import java.sql.ResultSet;
12-
import java.util.ArrayList;
138
import java.util.List;
149

1510
/**
@@ -38,6 +33,6 @@ public List<Table> findTableList() {
3833
* @return
3934
*/
4035
public List<Column> findColumnByTableName(String tableName) {
41-
return null;
36+
return new OracleColumnServiceImpl(tableName).findList(schema);
4237
}
4338
}

src/main/java/com/nzh/db/impl/OracleTableServiceImpl.java renamed to mybatis-tool-db/src/main/java/com/nzh/db/service/impl/OracleTableServiceImpl.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package com.nzh.db.impl;
1+
package com.nzh.db.service.impl;
22

3-
import com.nzh.db.ITableService;
3+
import com.nzh.db.model.Schema;
4+
import com.nzh.db.model.Table;
5+
import com.nzh.db.service.ITableService;
46
import com.nzh.db.QueryDb;
5-
import com.nzh.model.Schema;
6-
import com.nzh.model.Table;
77

88
import java.sql.Connection;
99
import java.sql.PreparedStatement;
@@ -23,7 +23,6 @@ protected void queryImpl(Connection con,PreparedStatement pre,ResultSet result)
2323
tableList.clear();
2424
String sql=selectTable;
2525
pre = con.prepareStatement(sql);// 实例化预编译语句
26-
//pre.setString(1, "刘显安");// 设置参数,前面的1表示参数的索引,而不是表中列名的索引
2726
result = pre.executeQuery();// 执行查询,注意括号中不需要再加参数
2827
while (result.next()) {
2928
String name=result.getString("name");

src/test/java/com/nzh/AppMainTest.java renamed to mybatis-tool-db/src/test/java/com/nzh/AppTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
import junit.framework.TestSuite;
66

77
/**
8-
* Unit test for simple AppMain.
8+
* Unit test for simple App.
99
*/
10-
public class AppMainTest
10+
public class AppTest
1111
extends TestCase
1212
{
1313
/**
1414
* Create the test case
1515
*
1616
* @param testName name of the test case
1717
*/
18-
public AppMainTest(String testName)
18+
public AppTest( String testName )
1919
{
2020
super( testName );
2121
}
@@ -25,7 +25,7 @@ public AppMainTest(String testName)
2525
*/
2626
public static Test suite()
2727
{
28-
return new TestSuite( AppMainTest.class );
28+
return new TestSuite( AppTest.class );
2929
}
3030

3131
/**

src/main/java/com/nzh/AppMain.java renamed to mybatis-tool-win/src/main/java/com/nzh/AppMain.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.nzh;
22

3+
import com.nzh.win.ui.MainFrame;
4+
35
/**
46
* 工具应用程序
57
* @author zhihuan.niu
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.nzh.win.model;
2+
3+
/**
4+
* @author zhihuan.niu on 2016/9/13.
5+
*/
6+
public class ColumnDto {
7+
//名称
8+
private String name;
9+
//备注
10+
private String comments;
11+
//类型
12+
private String type;
13+
//约束类型
14+
private String constraintType;
15+
//是否可空
16+
private boolean isNullAble;
17+
public String getName() {
18+
return name;
19+
}
20+
21+
public void setName(String name) {
22+
this.name = name;
23+
}
24+
25+
public String getComments() {
26+
return comments;
27+
}
28+
29+
public void setComments(String comments) {
30+
this.comments = comments;
31+
}
32+
33+
public String getType() {
34+
return type;
35+
}
36+
37+
public void setType(String type) {
38+
this.type = type;
39+
}
40+
41+
public String getConstraintType() {
42+
return constraintType;
43+
}
44+
45+
public void setConstraintType(String constraintType) {
46+
this.constraintType = constraintType;
47+
}
48+
49+
public boolean isNullAble() {
50+
return isNullAble;
51+
}
52+
53+
public void setIsNullAble(boolean isNullAble) {
54+
this.isNullAble = isNullAble;
55+
}
56+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.nzh.win.model;
2+
3+
import com.nzh.db.model.Table;
4+
5+
/**
6+
* @author zhihuan.niu on 2016/9/13.
7+
*/
8+
public class TableDto extends Table{
9+
public TableDto(Table table){
10+
setName(table.getName());
11+
}
12+
//过滤字段 如 fix fib ppm
13+
private String pre;
14+
15+
/**
16+
* 返回转行后的名字
17+
* @return FIB_INCREMENT>Increment
18+
*/
19+
public String getDtoName(){
20+
//FIB_INCREMENT
21+
return "Increment";
22+
}
23+
24+
}

src/main/java/com/nzh/MainFrame.java renamed to mybatis-tool-win/src/main/java/com/nzh/win/ui/MainFrame.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
package com.nzh;
1+
package com.nzh.win.ui;
22

3-
import com.nzh.db.ISchemaService;
4-
import com.nzh.db.impl.OracleSchemaServiceImpl;
5-
import com.nzh.model.Schema;
6-
import com.nzh.model.Table;
3+
import com.nzh.db.model.Column;
4+
import com.nzh.db.model.Schema;
5+
import com.nzh.db.model.Table;
6+
import com.nzh.db.service.ISchemaService;
7+
import com.nzh.db.service.impl.OracleSchemaServiceImpl;
78

89
import javax.swing.*;
910
import java.awt.event.ActionEvent;

pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
<groupId>com.nzh</groupId>
66
<artifactId>mybatis-tool</artifactId>
77
<version>1.0-SNAPSHOT</version>
8-
<packaging>jar</packaging>
8+
<modules>
9+
<module>mybatis-tool-db</module>
10+
<module>untitled</module>
11+
<module>mybatis-tool-win</module>
12+
</modules>
13+
<packaging>pom</packaging>
914

1015
<name>mybatis-tool</name>
1116
<url>http://maven.apache.org</url>
@@ -21,11 +26,6 @@
2126
<version>3.8.1</version>
2227
<scope>test</scope>
2328
</dependency>
24-
<!-- 添加oracle jdbc driver -->
25-
<dependency>
26-
<groupId>com.oracle</groupId>
27-
<artifactId>ojdbc6</artifactId>
28-
<version>11.2.0</version>
29-
</dependency>
29+
3030
</dependencies>
3131
</project>

0 commit comments

Comments
 (0)