title: SELECT * FROM <table> BETWEEN <value typed in a JTextField> AND <idem>
body: <p>EDIT4:</p>
  
  <p>I don't know why, but the structure I used below didn't work. I had to modify a file I found at java2s website, it's called TableFromDatabase, then make the JTextFields public static, then instantiating the TableFromDatabase class in FrmMovimento and etc:</p>
  
  <pre><code>TableFromDatabase frame = new TableFromDatabase();
  jDesktopPane2.add(frame);
  frame.show();
  </code></pre>
  
  <p>I also modified TableFromDatabase line</p>
  
  <pre><code>frame.setDefaultCloseOperation( EXIT_ON_CLOSE_ );
  </code></pre>
  
  <p>to</p>
  
  <pre><code>frame.setDefaultCloseOperation( DISPOSE_ON_CLOSE );
  </code></pre>
  
  <p>ORIGINAL POST:</p>
  
  <p>In this part of the program, the JInternalFrame file FrmMovimento, I made a button called Visualizar ("View"). Based on what we type on the text fields, it must show the interval the user defined.</p>
  
  <p>There are these JTextFields:
  Code from: <strong><em>_</em></strong> To: <strong><em>_</em></strong>
  Asset: <strong><em>_</em></strong></p>
  
  <p>And these JFormattedTextFields:
  Date from: <strong><em>_</em></strong> To: <strong><em>_</em></strong></p>
  
  <p>There are registers appearing already in the JDesktopPane from JInternalFrame FrmListarMov, if I use another SELECT statement selecting all registers, for example. But not if I type as I did in the title:</p>
  
  <pre><code>public List&lt;MovimentoVO&gt; Lista() throws ErroException, InformacaoException{
      List&lt;MovimentoVO&gt; listaMovimento = new ArrayList&lt;&gt; ();
      try {
  
          MySQLDAO.getInstancia().setAutoCommit(false);
          try (PreparedStatement stmt = MySQLDAO.getInstancia().prepareStatement(
               "SELECT * FROM Cadastro2 WHERE Codigo BETWEEN "+ txtCodDeMov +" AND "+ txtCodAteMov +";") {
  
              ResultSet registro = stmt.executeQuery();
  
              while(registro.next()){
  
                  MovimentoVO Movimento = new MovimentoVO();
  
                  Movimento.setCodDeMov(registro.getInt(1));
                  Movimento.setCodAteMov(registro.getInt(2));
                  Movimento.setAtivoMov(registro.getString(3));
                  Movimento.setDataDeMov(registro.getString(4));
                  Movimento.setDataAteMov(registro.getString(5));
  
                  listaMovimento.add(Movimento);
              }
          }
      } catch (SQLException ex) {            
            throw new ErroException(ex.getMessage());
       } catch (InformacaoException ex) {  
            throw ex;
      }
      return listaMovimento;
  }
  </code></pre>
  
  <p>In the SELECT line, txtCodDeMov is how I named the JTextField of "Code from" and txtCodAtemov is how I named the JTextField of the first "To".</p>
  
  <p>Oh, I'm using NetBeans 7.1.2 (Build 201204101705) and MySQL Ver 14.14 Distrib 5.1.63 in a Linux Mint 12 64-bits.</p>
  
  <p>EDIT: actually, it's MovimentoVO2, MovimentoDAO2 and so on, because I did two files, one with setCodDeMov and setCodAteMov etc. and another one with only setCodigo, setAtivo and setData. I'm still kind of noob in using these techniques, sorry.</p>
  
  <p>From table Cadastro2, only primary key Codigo will be used for the query.
  Later we'll create other table where we'll register buy and sell of assets, so they'll have the type of asset and movement date, which will be added to the SELECT ... BETWEEN ... AND we need. By now, I need only to understand how Java could get the value I typed in the JTextField and put it into the SELECT command.</p>
  
  <p>EDIT2: In the client registration screen, query button is working 100%, as follows. BUT it's a different situation, since in this case the button event makes all JTextFields to be completed if the register with specified Code (primary key in the table Cadastro2) is found. Now what I want to do is produce a table with all the registers in the interval.</p>
  
  <p>EDIT3: I think the correct term is REPORT GENERATING. I heard about iReport and Jasper Reports, but I never used them. Considering this project must be presented in December in the university, is there time to learn these 2 tools? As I'm learning Java still, would it be a bad move? At first I think it is, so I'm doing everything only on Netbeans.</p>