public class DataBaseMessage {
public static void main(String[] args) {
getMessage();
}
public static void getMessage(){
Connection connection = null;
ResultSet rs = null;
try {
connection = 獲取connection;
DatabaseMetaData dbMetaData = connection.getMetaData();
System.out.println("數(shù)據(jù)庫相關(guān)信息 : ");
System.out.println("已知的用戶: "+ dbMetaData.getUserName());
System.out.println("系統(tǒng)函數(shù)的逗號(hào)分隔列表: "+ dbMetaData.getSystemFunctions());
System.out.println("時(shí)間和日期函數(shù)的逗號(hào)分隔列表: "+ dbMetaData.getTimeDateFunctions());
System.out.println("字符串函數(shù)的逗號(hào)分隔列表: "+ dbMetaData.getStringFunctions());
System.out.println("供應(yīng)商用于 'schema' 的選術(shù)語: "+ dbMetaData.getSchemaTerm());
System.out.println("URL: " + dbMetaData.getURL());
System.out.println("是否允許只讀:" + dbMetaData.isReadOnly());
System.out.println("的產(chǎn)品名稱:" + dbMetaData.getDatabaseProductName());
System.out.println("版本:" + dbMetaData.getDatabaseProductVersion());
System.out.println("驅(qū)動(dòng)程序的名稱:" + dbMetaData.getDriverName());
System.out.println("驅(qū)動(dòng)程序的版本:" + dbMetaData.getDriverVersion());
//查詢t_file表格的所有信息
rs = dbMetaData.getColumns(null, null,"表名稱", null);
//獲取t_file表每條記錄的信息
while(rs.next()){
System.out.println();System.out.println();
String column_name = rs.getString("COLUMN_NAME");
String type_name = rs.getString("TYPE_NAME");
int column_size = rs.getInt("COLUMN_SIZE");
boolean is_nullable = rs.getBoolean("IS_NULLABLE");
String column_def = rs.getString("COLUMN_DEF");
System.out.println("column_name :"+column_name+" **** type_name :"+type_name+" **** column_size : "+column_size+" **** is_nullable : "+is_nullable +" **** column_def : "+column_def);
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
//connection.close();
//rs.close();
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
}
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
當(dāng)前名稱:java查看數(shù)據(jù)庫信息和對(duì)應(yīng)表的信息-創(chuàng)新互聯(lián)
文章路徑:http://jinyejixie.com/article16/dicpdg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、品牌網(wǎng)站設(shè)計(jì)、軟件開發(fā)、網(wǎng)頁設(shè)計(jì)公司、搜索引擎優(yōu)化、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容