Accessing the only element of Java ResultSet
Here is a bit reworked version of you code. Some explanation:


Assume _TABLE_NAME is a constant, so there is no need to build query in every method call. 
Force getting connection and close resources to avoid side effects.
Propagate SQLException to caller (caller should decide what to do with thrown exception).


Code:

private final static String GET_DATA_BY_ID = "select * from " + _TABLE_NAME + " where id = ?";

public Map&lt;String, String&gt; getById(long id) throws SQLException {

    Connection conn = null;
    Map&lt;String, String&gt; result = new HashMap&lt;String, String&gt;();

    try {
        conn = getConnection();

        PreparedStatement preparedStatement = null;

        ResultSet rs = null;
        try {
            preparedStatement = conn.prepareStatement(GET_DATA_BY_ID);
            preparedStatement.setLong(1, id);
            try {
                rs = preparedStatement.executeQuery();

                if (rs.next()) {
                    ResultSetMetaData rsmd = rs.getMetaData();
                    int fieldsCount = rsmd.getColumnCount();

                    for (int i = 1; i &lt; fieldsCount + 1; i++) {
                        String cName = rsmd.getColumnName(i);
                        result.put(cName, rs.getString(cName));
                    }
                }
            } finally {
                if (rs != null)
                    rs.close();
            }
        } finally {
            if (preparedStatement != null)
                preparedStatement.close();
        }
    } finally {
        if (conn != null)
            conn.close();
    }
    return result;
}