Spring JDBC ResultSetMetaData "getColumnName()" method returns an empty string
<p>I have the following section of code to implement a drop-down menu. Based on the two parameters selected from the menu, I run the corresponding query by replacing the selected column with the mapped column name.</p>

<pre><code>String sql = "SELECT ?, ? FROM &lt;table_name&gt;";

ArrayList&lt;Some_POJO&gt; res = this.jdbcTemplate.query(sql, new ResultSetExtractor&lt;Some_POJO&gt;()
    {//logic goes here.},
    user_inputs_as_object_array);
</code></pre>

<p>Now, in the logic section, I'm using the following command to map the returned values:</p>

<pre><code>while(rs.next()) {
    Some_POJO = new SOME_POJO();
    Some_POJO.setParam1(rs.getString("SOME_COLUMN_NAME")); //ERROR
}
</code></pre>

<p>Now, the marked line fails when I refer to column by name. But what is surprising is, the following workaround works:</p>

<pre><code>while(rs.next()) {
    Some_POJO = new SOME_POJO();
    int i = 1;
    Some_POJO.setParam1(rs.getString(i)); //Works(?!)
}
</code></pre>

<p>I tried to modify the JDBC template call to return the ResultSetMetaData object instead of an ArrayList of Some_POJO:</p>

<pre><code>String sql = "SELECT ?, ? FROM &lt;table_name&gt;";

ResultSetMetaData res = this.jdbcTemplate.query(sql, new ResultSetExtractor&lt;ResultSetMetaData&gt;()
    {//extractData now returns rs.getMetaData()},
    user_inputs_as_object_array);

try
    {
        System.out.println("Column cout: " + res.getColumnCount());
        for(int i = 1; i &lt;= res.getColumnCount(); i++)
            System.out.println("Label: " + res.getColumnLabel(i) +  "\nName: " + res.getColumnName(i));
    }
    catch(SQLException sqle)
</code></pre>

<p>Only to get:</p>

<pre><code>Column cout: 2
Label: :1
Name: 
Label: :2
Name:
</code></pre>

<p>Could someone please shed some light into what is happening and (except for suggestions suggesting a complete redesign) what would be the most optimal way to achieve the expected functionality? I would prefer not to use column indexes since order changes would break the functionality.</p>