Guest User

Untitled

a guest
Feb 7th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. public class Model extends Sql {
  2.  
  3. PreparedStatement s;
  4. //preparando variables necesarias
  5. protected PreparedStatement ps;
  6. protected String bd;
  7. protected Connection cn;
  8. protected Statement st;
  9. protected String sql;
  10. protected ResultSet rs;
  11.  
  12. String DatoFinales = "";
  13. String driverDataBase = "";
  14.  
  15. private Connection dbVerificadorConnection;
  16.  
  17. public Model() throws Exception {
  18.  
  19. String sqlserverProperties = Util.getProperties("sqlserver");
  20. String applicationNameProperties = Util.getProperties("applicationName");
  21. String databaseNameProperties = Util.getProperties("databaseName");
  22. String userProperties = Util.getProperties("user");
  23. String passwordProperties = Util.getProperties("password");
  24. String driverDataBaseProperties = Util.getProperties("driverDataBase");
  25.  
  26. DatoFinales += "jdbc:sqlserver:"
  27. + sqlserverProperties
  28. + ";applicationName="
  29. + applicationNameProperties
  30. + ";databaseName="
  31. + databaseNameProperties
  32. + ";user="
  33. + userProperties
  34. + ";password="
  35. + passwordProperties;
  36.  
  37. driverDataBase = driverDataBaseProperties;
  38. }
  39.  
  40. private void AbrirConexionBaseDatos() {
  41. try {
  42. Class.forName(driverDataBase); //inicializo el driver
  43. cn = DriverManager.getConnection(DatoFinales, new Properties()); //enlazo la tabla
  44. } catch (ClassNotFoundException | SQLException e) {
  45. Util.Exception(e);
  46. }
  47. }
  48.  
  49. private void CerrarConexionBaseDatos() throws SQLException {
  50. try {
  51. s.close();
  52. } catch (Exception e) {
  53. Util.Exception(e);
  54. }
  55. }
Add Comment
Please, Sign In to add comment