I am trying to make an app which import data from database and use it in another function.
I got connection with database and it returns me a variable called miejsce:
public void sprawdzAuto(String nrRej, String miejsce){
try{
String query = "select lokalizacja from samochody75 where nrRej=?";
PreparedStatement pst = con.prepareStatement(query);
pst.setString(1, nrRej);
ResultSet rs = pst.executeQuery();
while (rs.next()) {
miejsce = rs.getString(1);
System.out.println(miejsce);
}
JOptionPane.showMessageDialog(null, "Znaleziono.");
} catch(SQLException e) {
System.out.print(e);
}
}
Now when i got miejsce i want to use it in another .java file called Mapa.
public class Mapa extends MapView{
private Map map;
public Mapa(String nName)
{
JFrame frame = new JFrame(nName);
setOnMapReadyHandler(new MapReadyHandler() {
@Override
public void onMapReady(MapStatus status) {
if (status == MapStatus.MAP_STATUS_OK){
map=getMap();
MapOptions mapOptions = new MapOptions();
MapTypeControlOptions controlOptions= new MapTypeControlOptions();
mapOptions.setMapTypeControlOptions(controlOptions);
map.setOptions(mapOptions);
map.setCenter(new LatLng(1,1));
map.setZoom(17.0);
Marker mark = new Marker(map);
mark.setPosition(map.getCenter());
}
}
});
frame.add(this, BorderLayout.CENTER);
frame.setSize(700,500);
frame.setVisible(true);
}
}
I want result of miejsce to map.setCenter(); I tried diffrent things but none of them works. Is there any solution to make it possible?
Thank you in advance.