SpiderDB 是一个轻量级的数据库结构扒取工具,使用 Java 开发。它是一个简单的类库可根据数据库的表结构来生成 POJO 对象,使用简单,支持各种不同的数据库系统。
示例代码:
DBCrawler dbCrawler = new DBCrawler(connection, ConfigEnum.MAXIMUM); DataBase dataBase = dbCrawler.getDatabase(); System.out.println(“productName :” + dataBase.getProductName() + ” version:” + dataBase.getProductVersion());
//Return Schemas SchemaSet schemaSet = dataBase.getSchemaSet(); Set schemas = schemaSet.getSchemas(); //Iterate to Fetch the schema information and Tables for(Schema schema : schemas) { System.out.println(“SchemaName :” + schema.getSchamaName()); TableSet tableSet = schema.getTableSet(); Set tables = tableSet.getTables(); //Iterate to fetch the tables for(Table table : tables) { System.out.println(“tableName :” + table.getTableName()); PrimaryKey primaryKey = table.getPrimaryKey(); System.out.println(“pk_Name:”+primaryKey.getPkName() + ” PrimaryKey Columns:” + primaryKey.getColumns()); ColumnSet columnSet = table.getColumnSet(); System.out.println(“Table Columns:”+ columnSet.getColumns()); Set foreignKeys = table.getForeignKeys(); System.out.println(“foreignKeys:”+foreignKeys); } } 软件首页
ColumnSet columnSet = table.getColumnSet(); System.out.println(“Table Columns:”+ columnSet.getColumns());
Set foreignKeys = table.getForeignKeys(); System.out.println(“foreignKeys:”+foreignKeys); } }