Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. /*
  2. * MonitorFotovoltaicoApp.java
  3. */
  4.  
  5. package monitorfotovoltaico;
  6.  
  7. import bancoDeDados.AcessoBD;
  8. import java.sql.Timestamp;
  9.  
  10. import org.jdesktop.application.Application;
  11. import org.jdesktop.application.SingleFrameApplication;
  12.  
  13.  
  14. /**
  15. * The main class of the application.
  16. */
  17. public class MonitorFotovoltaicoApp extends SingleFrameApplication{
  18.  
  19. //nome do driver JDBC e URL do banco de dados
  20. static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
  21. static final String DATABASE_URL = "jdbc:mysql://localhost/fotovoltaico";
  22. static final String USERNAME = "root";
  23. static final String PASSWORD = "root";
  24. static AcessoBD acessoBD;
  25.  
  26. /*public MonitorFotovoltaicoApp()
  27. {
  28. acessoBD = new AcessoBD(JDBC_DRIVER, DATABASE_URL, USERNAME, PASSWORD);
  29. }*/
  30.  
  31. /**
  32. * At startup create and show the main frame of the application.
  33. */
  34. @Override protected void startup() {
  35. show(new MonitorFotovoltaicoView(this));
  36. }
  37.  
  38. /**
  39. * This method is to initialize the specified window by injecting resources.
  40. * Windows shown in our application come fully initialized from the GUI
  41. * builder, so this additional configuration is not needed.
  42. */
  43. @Override protected void configureWindow(java.awt.Window root) {
  44. }
  45.  
  46. /**
  47. * A convenient static getter for the application instance.
  48. * @return the instance of MonitorFotovoltaicoApp
  49. */
  50. public static MonitorFotovoltaicoApp getApplication() {
  51. return Application.getInstance(MonitorFotovoltaicoApp.class);
  52. }
  53.  
  54. /**
  55. * Main method launching the application.
  56. */
  57.  
  58. public static void main(String[] args)
  59. {
  60. launch(MonitorFotovoltaicoApp.class, args);
  61. acessoBD = new AcessoBD(JDBC_DRIVER, DATABASE_URL, USERNAME, PASSWORD);
  62. acessoBD.consultarBanco();
  63.  
  64. MyMetodos myMetodos = new MyMetodos();
  65.  
  66. System.out.printf("%s\n", myMetodos.getCurrentTimestamp());
  67. System.out.printf("%s\n", this.getCurrentTimestamp()); // nao aceita???
  68. //new MonitorFotovoltaicoApp();
  69. }
  70.  
  71. public String getCurrentTimestamp()
  72. {
  73. Timestamp current_timestamp = new Timestamp(System.currentTimeMillis());
  74. String my_timestamp = current_timestamp.toString();
  75. return my_timestamp.substring(0, 19);
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement