Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public String getShape(ClickedPoint point, String shapeType) {
- String sql = "SELECT * FROM " + shapeType + " WHERE CONTAINS(SHAPE,Point(" + point.getX() + "," + point.getY() + "));";
- try (
- Connection connection = DriverManager.getConnection(dbUrl, username, password);
- Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(sql)
- ) {
- if (resultSet.next()) {
- return parser.parseShape(resultSet);
- }
- throw new ResourceAccessException(SHAPE_NOT_FOUND);
- } catch (SQLException e) {
- throw new ResourceAccessException(e.getMessage());
- } catch (SchemaException | IOException e) {
- e.printStackTrace();
- throw new RuntimeException();
- //TODO: throw custom exception
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement