Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String ip, db, un, passwords;
- Connection con;
- PreparedStatement stmt;
- ResultSet rs;
- public void MarcadoreBdd(GoogleMap map) {
- ip = "mssql4.gear.host";
- db = "ciclomapp1";
- un = "ciclomapp1";
- passwords = "Mk36-9DX-580";
- String query = "select ru.nombre , ru.descripcion , avg(va.valoracion) ,re.tipo, ru.ubicacion n" +
- "from (Rutas ru inner join valorar va on ru.nombre=va.nombre_ruta) n" +
- "inner join reporte re on re.nombre_ruta =Ru.nombren" +
- "group by ru.nombre,ru.descripcion , va.valoracion ,re.tipo, ru.ubicacion; ";
- try {
- con = connectionclass(un, passwords, db, ip);
- stmt = con.prepareStatement(query);
- rs = stmt.executeQuery();
- while (rs.next()) {
- Ruta b = null;
- b.nombre = rs.getString("nombre");
- b.descripcion= rs.getString("descripcion");
- b.ubicacion= rs.getString("ubicacion");
- b.valoracion=rs.getString("valoracion").toString();
- b.reporte=rs.getString("reporte");
- String [] point=b.ubicacion.split(",");
- double latitude = Double.parseDouble(point[0]);
- double longitude = Double.parseDouble(point[1]);
- LatLng location = new LatLng(latitude, longitude);
- String valorar=String.valueOf(b.getValoracion());
- map.addMarker(new MarkerOptions().position(location).snippet(b.descripcion+ System.getProperty ("line.separator")+"Valoracion de la ruta"
- +valorar+System.getProperty ("line.separator")+"Estado de la ruta: Posible"+b.reporte));
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- @SuppressLint("NewApi")
- public Connection connectionclass (String user, String password, String database, String server){
- StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
- StrictMode.setThreadPolicy(policy);
- Connection connection = null;
- String ConnectionURL = null;
- try {
- Class.forName("net.sourceforge.jtds.jdbc.Driver");
- ConnectionURL = "jdbc:jtds:sqlserver://" + server + "/" + database + ";user=" + user + ";password=" + password + ";";
- connection = DriverManager.getConnection(ConnectionURL);
- } catch (SQLException se) {
- Log.e("error here 1 : ", se.getMessage());
- } catch (ClassNotFoundException e) {
- Log.e("error here 2 : ", e.getMessage());
- } catch (Exception e) {
- Log.e("error here 3 : ", e.getMessage());
- }
- return connection;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement