Advertisement
Guest User

Untitled

a guest
Oct 7th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6.  
  7. package modelo;
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.SQLException;
  11. import java.sql.Statement;
  12.  
  13. /**
  14. *
  15. * @author
  16. */
  17. public class ComentariosDAO {
  18. private Connection conexion;
  19.  
  20. private void abrirConexion() throws SQLException{
  21. String dbURI = "jdbc:derby://localhost:1527/Comentarios";
  22. String username = "fcfm";
  23. String password = "lsti01";
  24. conexion = DriverManager.getConnection(dbURI, username, password);
  25. }
  26.  
  27. private void cerrarConexion(){
  28. conexion.close();
  29. }
  30.  
  31. void insertar() throws SQLException {
  32. ComentariosPOJO COMENTARIOS;
  33. String dbURI = "jdbc:derby://localhost:1527/Comentarios";
  34. insert into COMENTARIOS values ('Ana', 'nunca es tarde')
  35. Statement stmt = conexion.createStatement();
  36. stmt.executeUpdate(sql);
  37. cerrarConexion();
  38. }
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement