title: How can I get the first blank row in a database?
body: <p>I'm writing in Java a simple program that write a database with informations inserted by user.
  I've implemented a Listener to a button that saves these informations, updating therefore a connected Server (so the connection is ok).
  I'd like to get the first blank row and write on it. In this way, I can write the entire database calling ever the same method.
  Any suggestion?
  this is the code (it begins from a listener)</p>
  
  <pre><code>Object src = e.getSource();
              if (src == insTeaching)
              {
                  String teachName = teachNameField.getText();
                  int studentsNumber = (int) studentsNumberSpinner.getValue();
                  DBConnect connection = new DBConnect();
  connection.updateDB(teachName, studentSNumber);
  }
  </code></pre>
  
  <p>where updateDB is the following method:</p>
  
  <pre><code>public void updateDB (String name, int student){ 
  try {
      String query1 = "UPDATE subject SET name='" + name
  +"', student='" + student+"' WHERE (conditions...);
      PreparedStatement statement=con.prepareStatement(query1);
      statement.executeUpdate();
  </code></pre>
  
  <p>Obviously this method can't work at this time.. how can I implemnts it for having the writing on the first blank row? In this way I can evoke the method every time the user click on the button..
  Is my situation clear?</p>
  
  <hr>
  
  <p>THIS is the Solution to my problem. I'd like to insert here this solution to help all the visitors that have my own problem.</p>
  
  <p>@Rahul, I've tried to do what you've written and it does not work. The problem is in "name is null". I've tried also "name = null", but nothing got better! So I changed the column matched: I've chosen Student (that had 0 as default value) and I wrote as you told me. So:</p>
  
  <pre><code>WHERE Student = '0' LIMIT 1
  </code></pre>
  
  <p>Limit 1 force the program to write ONLY the first and not all the other. Now it works! 
  So I thank you!</p>