fork download
  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. package Classes.Functions;
  7.  
  8. import Classes.Ui.DatePicker;
  9. import java.sql.Connection;
  10. import java.sql.PreparedStatement;
  11. import java.sql.ResultSet;
  12. import javax.swing.JOptionPane;
  13. import javax.sql.*;
  14. import javax.swing.JFrame;
  15. import javax.swing.JPanel;
  16. import net.proteanit.sql.DbUtils;
  17. /**
  18.  *
  19.  * @author takajima
  20.  */
  21. public class NewJFrame extends javax.swing.JFrame {
  22.  
  23. /**
  24.   * Creates new form NewJFrame
  25.   */
  26.  
  27. PreparedStatement ps = null;
  28. Connection conn = null;
  29. ResultSet rs = null;
  30. public NewJFrame() {
  31. initComponents();
  32. Datepicker_end();
  33. conn = Classes.Database.MySqlDatabase.ConnectorDB();
  34. }
  35.  
  36. public void Datepicker_end() {
  37.  
  38.  
  39. try {
  40. String sqlQuery = "SELECT * From Sales";
  41. ps = conn.prepareStatement(sqlQuery);
  42. rs = ps.executeQuery();
  43. jTable1.setModel(DbUtils.resultSetToTableModel(rs));
  44. } catch (Exception e) {
  45. JOptionPane.showMessageDialog(null, e);
  46. } finally {
  47. try {
  48. rs.close();
  49. ps.close();
  50. } catch (Exception e) {
  51. JOptionPane.showMessageDialog(null, e);
  52. }
  53. }
  54. }
  55.  
  56. /**
  57.   * This method is called from within the constructor to initialize the form.
  58.   * WARNING: Do NOT modify this code. The content of this method is always
  59.   * regenerated by the Form Editor.
  60.   */
  61. @SuppressWarnings("unchecked")
  62. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  63. private void initComponents() {
  64.  
  65. jScrollPane1 = new javax.swing.JScrollPane();
  66. jTable1 = new javax.swing.JTable();
  67.  
  68. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  69.  
  70. jTable1.setModel(new javax.swing.table.DefaultTableModel(
  71. new Object [][] {
  72. {null, null, null, null},
  73. {null, null, null, null},
  74. {null, null, null, null},
  75. {null, null, null, null}
  76. },
  77. new String [] {
  78. "Title 1", "Title 2", "Title 3", "Title 4"
  79. }
  80. ));
  81. jScrollPane1.setViewportView(jTable1);
  82.  
  83. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  84. getContentPane().setLayout(layout);
  85. layout.setHorizontalGroup(
  86. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  87. .addGroup(layout.createSequentialGroup()
  88. .addGap(179, 179, 179)
  89. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  90. .addContainerGap(239, Short.MAX_VALUE))
  91. );
  92. layout.setVerticalGroup(
  93. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  94. .addGroup(layout.createSequentialGroup()
  95. .addGap(50, 50, 50)
  96. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  97. .addContainerGap(108, Short.MAX_VALUE))
  98. );
  99.  
  100. pack();
  101. }// </editor-fold>
  102.  
  103. /**
  104.   * @param args the command line arguments
  105.   */
  106. public static void main(String args[]) {
  107. /* Set the Nimbus look and feel */
  108. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  109. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  110.   * For details see http://d...content-available-to-author-only...e.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  111.   */
  112. try {
  113. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  114. if ("Nimbus".equals(info.getName())) {
  115. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  116. break;
  117. }
  118. }
  119. } catch (ClassNotFoundException ex) {
  120. java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  121. } catch (InstantiationException ex) {
  122. java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  123. } catch (IllegalAccessException ex) {
  124. java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  125. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  126. java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  127. }
  128. //</editor-fold>
  129.  
  130. /* Create and display the form */
  131. java.awt.EventQueue.invokeLater(new Runnable() {
  132. public void run() {
  133. new NewJFrame().setVisible(true);
  134. }
  135. });
  136. }
  137.  
  138. // Variables declaration - do not modify
  139. private javax.swing.JScrollPane jScrollPane1;
  140. private javax.swing.JTable jTable1;
  141. // End of variables declaration
  142. }
  143.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:21: error: class NewJFrame is public, should be declared in a file named NewJFrame.java
public class NewJFrame extends javax.swing.JFrame {
       ^
Main.java:8: error: package Classes.Ui does not exist
import Classes.Ui.DatePicker;
                 ^
Main.java:16: error: package net.proteanit.sql does not exist
import net.proteanit.sql.DbUtils;
                        ^
Main.java:33: error: package Classes.Database does not exist
        conn = Classes.Database.MySqlDatabase.ConnectorDB();
                               ^
Main.java:43: error: cannot find symbol
            jTable1.setModel(DbUtils.resultSetToTableModel(rs));
                             ^
  symbol:   variable DbUtils
  location: class NewJFrame
5 errors
stdout
Standard output is empty