title: JUnit testing SQL queries
body: <p>I'm working on a project and we are required to create some test cases. I have a SQL database and parsing data there with queries like: </p>
  
  <pre><code>public Contractor create(String name, String address, String email, String phone, String city, int cvr) throws SQLException{
      Contractor contractor = new Contractor(name, address, email, phone, city, cvr);
      String sql = String.format("INSERT INTO person (name, address, email, phone, city, category) VALUES ('%s', '%s', '%s', '%s', '%s', 2)", name, address, email, phone, city);
      try{
          Connection conn = DBConnection.getInstance().getDBcon();
          conn.createStatement().executeUpdate(sql);
  
          String sql2 = "SELECT TOP 1 id FROM Person ORDER BY id DESC";
          ResultSet rs = conn.createStatement().executeQuery(sql2);
  
          if(rs.next()) {
              String sql3 = "INSERT INTO contractor (cvr, person_id) VALUES (2666,"+rs.getInt("id")+")";
              conn.createStatement().executeUpdate(sql3);
          }else{
              throw new SQLException();
          }
  
      } catch (SQLException e){
          e.printStackTrace();
      } finally {
          DBConnection.closeConnection();
      }
      return contractor;
  }    
  </code></pre>
  
  <p>How would the test with JUnits look like?</p>