@@ -33,6 +33,8 @@ public class DatabaseConfig implements Serializable {
33
33
public SimpleStringProperty databaseType = new SimpleStringProperty ("MySQL" );
34
34
@ Config (bundle = "database.dbName" )
35
35
public SimpleStringProperty dbName = new SimpleStringProperty ("" );
36
+ @ Config (bundle = "database.tableNamePattern" , testRegex = "%" , type = ConfigType .ComboBox )
37
+ public SimpleStringProperty tableNamePattern = new SimpleStringProperty ("%" );
36
38
@ Config (bundle = "database.host" )
37
39
public SimpleStringProperty host = new SimpleStringProperty ("localhost" );
38
40
@ Config (bundle = "database.port" )
@@ -96,6 +98,8 @@ public TreeItem<String> getRootTreeItem() {
96
98
public void connect () throws SQLException {
97
99
if (tableConfigs != null && tableConfigs .size () != 0 ) return ;
98
100
tableConfigs = new Hashtable <>();
101
+ if (tableNamePattern .getValue ().isEmpty ())
102
+ tableNamePattern .setValue ("%" );
99
103
Connection connection = getConnection ();
100
104
DatabaseMetaData meta = connection .getMetaData ();
101
105
ResultSet rs ;
@@ -105,32 +109,36 @@ public void connect() throws SQLException {
105
109
//获取表列表
106
110
switch (DatabaseType .valueOf (databaseType .getValue ())) {
107
111
case MySQL :
108
- rs = meta .getTables (null , dbName .getValue (), null , types );
112
+ rs = meta .getTables (
113
+ dbName .getValue ().isEmpty () ? null : dbName .getValue ()
114
+ , "%"
115
+ , tableNamePattern .getValue ()
116
+ , types );
109
117
break ;
110
118
case Oracle :
111
119
case Oracle_SID :
112
120
case Oracle_ServiceName :
113
121
case Oracle_TNSName :
114
122
case Oracle_TNSEntryString :
115
- rs = meta .getTables (null , userName .getValue ().toUpperCase (), null , types );
123
+ rs = meta .getTables (null , userName .getValue ().toUpperCase (), tableNamePattern . getValue () , types );
116
124
break ;
117
125
case SQLServer :
118
126
case SQLServer_InstanceBased :
119
127
sql = "select name as TABLE_NAME from sysobjects where xtype='u' or xtype='v' " ;
120
128
rs = connection .createStatement ().executeQuery (sql );
121
129
break ;
122
130
case PostgreSQL :
123
- rs = meta .getTables (null , "%" , "%" , types );
131
+ rs = meta .getTables (null , "%" , tableNamePattern . getValue () , types );
124
132
break ;
125
133
case DB2MF :
126
134
case DB2 :
127
- rs = meta .getTables (null , "jence_user" , "%" , types );
135
+ rs = meta .getTables (null , "jence_user" , tableNamePattern . getValue () , types );
128
136
break ;
129
137
case SYBASE :
130
- rs = meta .getTables (null , null , "%" , types );
138
+ rs = meta .getTables (null , null , tableNamePattern . getValue () , types );
131
139
break ;
132
140
case INFORMIX :
133
- rs = meta .getTables (null , null , "%" , types );
141
+ rs = meta .getTables (null , null , tableNamePattern . getValue () , types );
134
142
break ;
135
143
default :
136
144
throw new RuntimeException (Constants .getI18nStr ("msg.unsupportedDatabase" ));
0 commit comments