Skip to content

Instantly share code, notes, and snippets.

@jayendra13
Created September 21, 2022 11:00
Show Gist options
  • Save jayendra13/eec6231f6da34f7086063e26143ce4d8 to your computer and use it in GitHub Desktop.
Save jayendra13/eec6231f6da34f7086063e26143ce4d8 to your computer and use it in GitHub Desktop.
package com.brums.app;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
public class App {
public static void main(String[] args) {
Connection conn = null;
try {
String dbURL = "jdbc:sqlserver://<IP_ADDRESS>;trustServerCertificate=false;integratedSecurity=false;encrypt=false;";
String user = "sa";
String pass = "F0rt3chPr3ca";
// DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
conn = DriverManager.getConnection(dbURL, user, pass);
if (conn != null) {
DatabaseMetaData dm = (DatabaseMetaData) conn.getMetaData();
System.out.println("Driver name: " + dm.getDriverName());
System.out.println("Driver version: " + dm.getDriverVersion());
System.out.println("Product name: " + dm.getDatabaseProductName());
System.out.println("Product version: " + dm.getDatabaseProductVersion());
}
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
if (conn != null && !conn.isClosed()) {
conn.close();
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment