Прочитать значения переменных Java

public class MainActivity extends AppCompatActivity {

    public static TextView latitude;
    public static TextView longitude;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        latitude = (TextView) findViewById(R.id.lat);
        longitude = (TextView) findViewById(R.id.lon);
    }

    public static class Jdbc {

        public static void main(String[] args) throws SQLException, ClassNotFoundException {
            Class.forName("org.h2.Driver");

            String url = "jdbc:mysql://localhost/coord";
            String user = "user";
            String password = "pass";

            Connection connection = DriverManager.getConnection(url, user, password);
            Statement statement = connection.createStatement();
            String sql = "select * from geo";
            ResultSet result = statement.executeQuery(sql);
            while (result.next()) {
                long lat = result.getLong("lat");
                long lon = result.getLong("lon");
            }
        }
    }

Подскажите, пожалуйста, как прочитать значения переменных long lat и long lon через setText?


Ответы (0 шт):