📄 getsourcetabname.java
字号:
package com.unimas.dbsync.manage;
import com.unimas.dbsync.input.SourceDataBase;
import com.unimas.dbsync.entity.SourceDataBaseBean;
import java.sql.*;
/**
* Created by IntelliJ IDEA.
* User: 孔加亮
* Date: 2008-12-10
* Time: 16:05:32.
*/
/**
* 获取源端数据库的所有表名
* 而且返回能否连通数据库的true or false
*/
public class GetSourceTabName {
public boolean getSourceTabName(SourceDataBaseBean bean) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
boolean bl = false;
String SourceTabNames = "";
try {
conn = SourceDataBase.getInstance().getConnection();
stmt = conn.createStatement();
DatabaseMetaData dmd = conn.getMetaData();
rs = dmd.getTables(null, null, "%", null);
while (rs.next()) {
SourceTabNames += rs.getString(3) + "\n";
System.out.println("表的名称" + SourceTabNames);
}
bean.setTablesName(SourceTabNames);
if (conn != null) {
bl = true;
}
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
}
finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}
SourceDataBase.getInstance().closeConnection(conn);
}
return bl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -