简体   繁体   中英

How to get the OS information and the Databases that are installed on a machine whose IP address known using Java?

I am going to create a tool which shows the OS and Databases related information of a machine. I have the IP address/Host Name of a machine. Using the IP Address/Host Name of that machine I want to get the OS and Databases related information.

I need the information of databases(Like Oracle, MySQL, SQL Server..) without actually connect to the databases.

Is there any library available to get this information.

Well, some basic OS information is available in the default JVM system properties .

As for finding active databases, you could use some popular JDBC libraries to try and connect to default ports and infer their existence based on "connection refused" errors versus "invalid login" but that will only get you so far, especially if they are listening on non-default ports or domain sockets. You could also search the filesystem for installation folders or the Windows registry for telltale installation keys and infer their existence that way.

But ultimately, there's only so much you can discover on an unknown system without elevated (administrator) access.

For Database Information you need to import this java.sql.DatabaseMetaData;

Connection conn = getConnection();

DatabaseMetaData mtdt = conn.getMetaData();
System.out.println("DBMS name: " + mtdt.getDatabaseProductName());
System.out.println("DBMS version: " + mtdt.getDatabaseProductVersion());
System.out.println("Driver name: " + mtdt.getDriverName());

For OS information

System.out.println("\nName of the OS: " + System.getProperty("os.name"));
System.out.println("Version of the OS: " +   System.getProperty("os.version"));
System.out.println("Architecture of THe OS: " + System.getProperty("os.arch"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM