...
int i = 1;
//Ciclo de lectura del resultset
while(rs.next())
{
dato = rs.getString("Mensaje") ;
solucion = solucion + "<TR>";
solucion = solucion + "<TD width="20%"><i><input type="button" style="font-size:small" name="sms" + i + "" value="SMS" onclick ="abrir(" + dato + ");"/></i></TD>";
solucion = solucion + "</TR>";
i++;
}
...