Advertisement
Guest User

Untitled

a guest
Dec 4th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package com.mycompany.projetourb;
  7.  
  8. import java.sql.Connection;
  9.  
  10. import java.sql.DriverManager;
  11. import java.sql.PreparedStatement;
  12. import java.sql.ResultSet;
  13. import java.sql.SQLException;
  14. import java.util.ArrayList;
  15. import java.util.List;
  16. import java.util.Scanner;
  17. import java.util.logging.Level;
  18. import java.util.logging.Logger;
  19. import org.simmetrics.StringMetric;
  20. import static org.simmetrics.builders.StringDistanceBuilder.with;
  21. import static org.simmetrics.builders.StringMetricBuilder.with;
  22. import org.simmetrics.metrics.SmithWaterman;
  23.  
  24. public class Main {
  25.  
  26. public static void main(String[] args) throws ClassNotFoundException, SQLException {
  27. Connection con = null;
  28. try {
  29. con = DriverManager.getConnection(
  30. "jdbc:postgresql://127.0.0.1:5432/projeto", "postgres",
  31. "ALUNO");
  32. } catch (SQLException e) {
  33.  
  34. System.out.println("Falha na conexão");
  35. e.printStackTrace();
  36. }
  37.  
  38. if (con != null) {
  39. System.out.println("Conexão realizada com sucesso!");
  40. } else {
  41. System.out.println("Erro ao conectar");
  42.  
  43. }
  44.  
  45. Scanner sc = new Scanner(System.in);
  46. System.out.println("Digite o endereço a ser pesquisado: ");
  47. String pesquisa = sc.nextLine();
  48.  
  49. String sql = "select * from ruas where municipio = 'Lages' and uf = 'SC'";
  50. PreparedStatement ps = con.prepareStatement(sql);
  51. ResultSet rs = ps.executeQuery();
  52.  
  53. List<Ruas> listaRuas = new ArrayList<>();
  54.  
  55. while (rs.next()) {
  56. Ruas ruas = new Ruas();
  57. ruas.setNomeRua(rs.getString("nome"));
  58. listaRuas.add(ruas);
  59. }
  60.  
  61. StringMetric comparador = with(new SmithWaterman()).build();
  62.  
  63.  
  64.  
  65. for(Ruas ruas : listaRuas) {
  66.  
  67. }
  68.  
  69. //Comparar todos os nomes no for each com a pesquisa, e a string que tiver o valor maior, jogar numa proxima pesquisa SQL para o geom
  70.  
  71. }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement