Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. /*
  2. * Decompiled with CFR 0_115.
  3. */
  4. import java.io.PrintStream;
  5. import java.sql.Connection;
  6. import java.sql.DatabaseMetaData;
  7. import java.sql.DriverManager;
  8. import java.sql.SQLException;
  9.  
  10. public class conectaDB {
  11. public static void main(String[] args) {
  12. Connection conn = null;
  13. try {
  14. try {
  15. String dbURL = "jdbc:sqlserver://localhost\\sqlexpress";
  16. String user = "prueba";
  17. String pass = "Ab123.*";
  18. conn = DriverManager.getConnection(dbURL, user, pass);
  19. if (conn != null) {
  20. DatabaseMetaData dm = conn.getMetaData();
  21. System.out.println("Driver name: " + dm.getDriverName());
  22. System.out.println("Driver version: " + dm.getDriverVersion());
  23. System.out.println("Product name: " + dm.getDatabaseProductName());
  24. System.out.println("Product version: " + dm.getDatabaseProductVersion());
  25. }
  26. }
  27. catch (SQLException ex) {
  28. ex.printStackTrace();
  29. try {
  30. if (conn != null && !conn.isClosed()) {
  31. conn.close();
  32. }
  33. }
  34. catch (SQLException ex) {
  35. ex.printStackTrace();
  36. }
  37. }
  38. }
  39. finally {
  40. try {
  41. if (conn != null && !conn.isClosed()) {
  42. conn.close();
  43. }
  44. }
  45. catch (SQLException ex) {
  46. ex.printStackTrace();
  47. }
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement