Reputation: 9113
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.
Upvotes: 0
Views: 143
Reputation: 3911
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"));
Upvotes: 2
Reputation: 156534
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.
Upvotes: 2