Java 中的元數據
Java中的元數據,定義為關於數據的數據,稱為「元數據」。元資料也被認為是有關使用者所需資訊的文檔。這是資料倉儲的重要面向之一。
廣告 該類別中的熱門課程 JAVA 掌握 - 專業化 | 78 課程系列 | 15 次模擬測驗即時範例:圖書館目錄、目錄、有關人員資料的資料項目(人員體重、人員行走等)等
元資料由下列內容組成:
- 系統及其組件的描述和位置。
- 它還有資料和最終使用者視圖的名稱、定義、內容和結構。
- 權威資料辨識。
- 積分和轉換規則用於填充資料。
- 訂閱者的訂閱資訊。
- 用於分析資料使用情況和效能。
為什麼需要元資料?
它為 Java 開發人員提供有關表資料、庫目錄等內容和結構的資訊。
元資料型別
有 3 種類型的元資料:
- 操作元資料
- 擷取與轉換元資料
- 最終用戶元資料
1。操作元資料:操作元資料擁有操作資料來源的所有資訊。資料倉儲在從來源系統中選擇資訊時,會對記錄進行劃分,結合不同來源的文件因素,並處理多種編碼方案和欄位長度。當我們將資訊傳遞給最終用戶時,我們必須能夠返回來源資料集。
2。提取和轉換元資料:提取和轉換元資料包括有關從來源系統中刪除資料的資料。資料提取的提取方法、頻率和業務規則屬於提取和轉換元資料。
3。最終用戶元資料:最終用戶元資料是資料室的導航圖。它使最終用戶能夠從資料倉儲中找到資料。
元資料在 Java 中如何運作?
Java 元資料是基於提供給它的資料工作。它提供了有關數據的數據資訊。
文法:
class Metadata{ public static void main(String args[]){ try{ //load required database class //creating database metadata class DatabaseMetaData metaData=con.getMetaData(); //display the metadata of the table content System.out.println(metaData.getDriverName()); System.out.println(metaData.getDriverVersion()); System.out.println(metaData.getUserName()); System.out.println(metaData.getDatabaseProductName()); System.out.println(metaData.getDatabaseProductVersion()); con.close(); }catch(Exception e){ System.out.println(e);} } }注意: 在進入範例之前,您必須需要 MySQL 資料庫和 mysql-connector jar。
用 Java 實作元資料的範例
以下是 Java 中元資料的範例:
範例 #1 – 結果集元資料
代碼:
import java.sql.*;//importing sql package public class A {//Creating class //main method for run the application public static void main(String args[]) { try { //loading my sql driver Class.forName("com.mysql.jdbc.Driver"); //get the connection by providing database, user name and password Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root"); //select the all from employee table PreparedStatement preparedStatement = connection.prepareStatement("select * from employee"); //executing the query ResultSet resultSet = preparedStatement.executeQuery(); //Create result meta data for get the meta data of table ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); //Displaying meta data of employee table System.out.println("Total Number of columns: " + resultSetMetaData.getColumnCount()); System.out.println("1st Column name : " + resultSetMetaData.getColumnName(1)); System.out.println("2nd Column name : " + resultSetMetaData.getColumnName(2)); System.out.println("3rd Column name : " + resultSetMetaData.getColumnName(3)); System.out.println("Column Type Name of 1st column: " + resultSetMetaData.getColumnTypeName(1)); System.out.println("Column Type Name of 2nd column: " + resultSetMetaData.getColumnTypeName(2)); System.out.println("Column Type Name of 3rd column: " + resultSetMetaData.getColumnTypeName(3)); connection.close(); } catch (Exception e) { System.out.println(e); } } }
輸出:
範例 #2 – 資料庫元資料
代碼:
import java.sql.*;//importing sql package public class A {//Creating class //main method for run the application public static void main(String args[]) { try { //loading my sql driver Class.forName("com.mysql.jdbc.Driver"); //get the connection by providing database, user name and password Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root"); //select the all from employee table PreparedStatement preparedStatement = connection.prepareStatement("select * from employee"); //executing the query preparedStatement.executeQuery(); //Create databse result set meta data for get the meta data of databse of mysql DatabaseMetaData databaseMetaData=connection.getMetaData(); //Displaying meta data of mysql table System.out.println("MYSQL Driver Name: "+databaseMetaData.getDriverName()); System.out.println("MYSQL Driver Version: "+databaseMetaData.getDriverVersion()); System.out.println("MYSQL UserName: "+databaseMetaData.getUserName()); System.out.println("MYSQL Database Product Name:"+databaseMetaData.getDatabaseProductName()); System.out.println("MYSQL Database Product Version: "+databaseMetaData.getDatabaseProductVersion()); connection.close(); } catch (Exception e) { System.out.println(e); } } }
輸出:
範例 #3 – 用於擷取表格名稱的資料庫元資料
代碼:
import java.sql.*;//importing sql package public class A {// Creating class // main method for run the application public static void main(String args[]) { try { // loading my sql driver Class.forName("com.mysql.jdbc.Driver"); // get the connection by providing database, user name and password Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root"); // Create databse result set meta data for get the meta data of // databse of mysql DatabaseMetaData dbmd = connection.getMetaData(); String table[] = { "VIEW" }; ResultSet resultSet = dbmd.getTables(null, null, null, table); // iterating number table names from database of mysql while (resultSet.next()) { System.out.println("Table name is: "+resultSet.getString(3)); } connection.close(); } catch (Exception e) { System.out.println(e); } } }
輸出:
結論
Java中的元資料用於了解資料的資料。例如,表格欄位名稱、欄位資料類型、欄位資料類型長度、資料庫表格名稱、特定資料庫中存在的資料庫數量等
以上是Java 中的元數據的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undress AI Tool
免費脫衣圖片

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

容器化Java應用:創建Dockerfile,使用基礎鏡像如eclipse-temurin:17-jre-alpine,複製JAR文件並定義啟動命令,通過dockerbuild構建鏡像並用dockerrun測試本地運行。 2.推送鏡像到容器註冊表:使用dockertag標記鏡像並推送到DockerHub等註冊表,需先登錄dockerlogin。 3.部署到Kubernetes:編寫deployment.yaml定義Deployment,設置副本數、容器鏡像和資源限制,編寫service.yaml創建

Importjava.ioandjava.net.SocketforI/Oandsocketcommunication.2.CreateaSocketobjecttoconnecttotheserverusinghostnameandport.3.UsePrintWritertosenddataviaoutputstreamandBufferedReadertoreadserverresponsesfrominputstream.4.Usetry-with-resourcestoautomati

AwhileloopinJavarepeatedlyexecutescodeaslongastheconditionistrue;2.Initializeacontrolvariablebeforetheloop;3.Definetheloopconditionusingabooleanexpression;4.Updatethecontrolvariableinsidethelooptopreventinfinitelooping;5.Useexampleslikeprintingnumber

runthewindowsupdatetrubloubleshooterviaSettings>更新&安全> is esseShootsoAtomationfixCommonissues.2.ResetWindowSupDateComponentsByStoppingRealatedServices,RenamingTheSoftWaredWaredWaredSoftwaredSistribution andCatroot2Folders,intrestrestartingthertingthertingtherserviceSteStoceTocle

JavaserializationConvertSanObject'SstateIntoAbyTeSteAmForStorageorTransermission,andDeserializationReconstructstheObjectStheObjectFromThstream.1.toenableserialization,aclassMustimustimplementTheSerializableizableface.2.UseObjectObjectObjectObjectOutputputputputputtreamToserialializeanobectizeanobectementeabectenobexpent,savin

ahashmapinjavaiSadattrastureturethatStoreskey-valuepairsforefficeFitedReval,插入和deletion.itusesthekey’shashcode()methodtodeTermInestorageLageLageAgeLageAgeAgeAgeAgeAneStorageAgeAndAllowSavereo(1)timecomplexityforget()

NumPy數組的使用包括:1.創建數組(如從列表、全零、全一、範圍創建);2.形狀操作(reshape、轉置);3.向量化運算(加減乘除、廣播、數學函數);4.索引與切片(一維和二維操作);5.統計計算(最大值、最小值、均值、標準差、求和及軸向操作);這些操作高效且無需循環,適合大規模數值計算,最終掌握需多加練習。

選擇:linkedhashsetForinsertionorder,andreesetForsortedOrder.2.addelementswithadd()andremoveWithRemove()
