Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. @Override
  2. public String getShape(ClickedPoint point, String shapeType) {
  3.  
  4. String sql = "SELECT * FROM " + shapeType + " WHERE CONTAINS(SHAPE,Point(" + point.getX() + "," + point.getY() + "));";
  5.  
  6. try (
  7. Connection connection = DriverManager.getConnection(dbUrl, username, password);
  8. Statement statement = connection.createStatement();
  9. ResultSet resultSet = statement.executeQuery(sql)
  10. ) {
  11. if (resultSet.next()) {
  12. return parser.parseShape(resultSet);
  13. }
  14.  
  15. throw new ResourceAccessException(SHAPE_NOT_FOUND);
  16. } catch (SQLException e) {
  17. throw new ResourceAccessException(e.getMessage());
  18. } catch (SchemaException | IOException e) {
  19. e.printStackTrace();
  20. throw new RuntimeException();
  21. //TODO: throw custom exception
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement