Skip to content

Instantly share code, notes, and snippets.

@johnbahamon
Created October 20, 2016 17:47
Show Gist options
  • Save johnbahamon/eebd37ec0172498046e1e6119831bf12 to your computer and use it in GitHub Desktop.
Save johnbahamon/eebd37ec0172498046e1e6119831bf12 to your computer and use it in GitHub Desktop.
/*
* Decompiled with CFR 0_115.
*/
import java.io.PrintStream;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
public class conectaDB {
public static void main(String[] args) {
Connection conn = null;
try {
try {
String dbURL = "jdbc:sqlserver://localhost\\sqlexpress";
String user = "prueba";
String pass = "Ab123.*";
conn = DriverManager.getConnection(dbURL, user, pass);
if (conn != null) {
DatabaseMetaData dm = 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();
try {
if (conn != null && !conn.isClosed()) {
conn.close();
}
}
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