Guest User

Untitled

a guest
Jul 15th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. package persistencia;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6. import java.sql.Statement;
  7.  
  8. public class Serializacion {
  9.  
  10. private static Connection conn;
  11. private static Serializacion _singleton;
  12.  
  13. /*static {
  14. try
  15. {
  16. _singleton=new Serializacion();
  17. }
  18. catch(SQLException e){}
  19. catch(ClassNotFoundException e){}
  20. }*/
  21.  
  22.  
  23.  
  24. private Serializacion() throws SQLException ,ClassNotFoundException{
  25. Class.forName("org.hsqldb.jdbcDriver");
  26. conn = DriverManager.getConnection("jdbc:hsqldb:file:./datos/basededatos");
  27. }
  28.  
  29.  
  30.  
  31. public static Connection getConexion()
  32. {
  33. return conn;
  34. }
  35.  
  36. public static Serializacion getSerializacion()
  37. {
  38. return _singleton;
  39. }
  40.  
  41. public static void saveData() throws ClassNotFoundException,SQLException
  42. {
  43.  
  44. Statement st = conn.createStatement();
  45. st.executeUpdate("SHUTDOWN");
  46.  
  47. st.close();
  48. conn.close();
  49. }
  50. }
Add Comment
Please, Sign In to add comment