Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package sqltest;
- import java.sql.Connection;
- import java.sql.DatabaseMetaData;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- /**
- *
- * @author Abdullah
- */
- public class ScheemaInfo {
- public static void main(String[] args) throws SQLException{
- String catalog=null;
- String SchemaPattern=null;
- String tableNamePattern=null;
- String coulmnNamePattern=null;
- String Types[]=null;
- String url="jdbc:mysql://localhost:3306/demo?autoReconnect&useSSL=false";
- String user="root" ;
- String password="abdullah";
- Connection connect=DriverManager.getConnection(url,user, password);
- DatabaseMetaData MD=connect.getMetaData();
- ResultSet result= MD.getTables(catalog, SchemaPattern, tableNamePattern, Types);
- System.out.println("List of Tables");
- System.out.println("--------------------------------------");
- while(result.next()){
- System.out.println(result.getString("TABLE_NAME"));
- }
- System.out.println("List of Columns");
- System.out.println("------------------------------------------");
- ResultSet result1=MD.getColumns(catalog, SchemaPattern, tableNamePattern, coulmnNamePattern);
- while(result1.next()){
- System.out.println(result1.getString("COLUMN_NAME"));
- }
- }
- }
Add Comment
Please, Sign In to add comment