Created
October 20, 2016 17:47
-
-
Save johnbahamon/eebd37ec0172498046e1e6119831bf12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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