Giter Site home page Giter Site logo

Comments (9)

cipianpascu avatar cipianpascu commented on June 23, 2024 1

Hey Alen,
All good now, thank you
Best Regards,
Ciprian

from distributed-lock.

ssiahetiong avatar ssiahetiong commented on June 23, 2024

same issue with sqlserver:

org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [DELETE FROM `locked` WHERE expireAt < ?;]; SQL state [S0001]; error code [102]; Incorrect syntax near '`'.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '`'.
	at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1542)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:667)
	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:960)
	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:1015)
	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:1025)
	at com.github.alturkovic.lock.jdbc.service.SimpleJdbcLockSingleKeyService.acquire(SimpleJdbcLockSingleKeyService.java:51)

from distributed-lock.

alturkovic avatar alturkovic commented on June 23, 2024

I currently don't have the time to tackle this, if any of you have time to solve this, I would be happy to merge a PR.

from distributed-lock.

cipianpascu avatar cipianpascu commented on June 23, 2024

Hi Guys,

I tried to create a pull request, but I've got some errors. Maybe it is because of firewall issues.
Please find bellow the queries tested with oracle:

public static final String ACQUIRE_FORMATTED_QUERY = "INSERT INTO %s (lock_key, token, expireAt) VALUES (?, ?, ?)";
public static final String RELEASE_FORMATTED_QUERY = "DELETE FROM %s WHERE lock_key = ? AND token = ?";
public static final String DELETE_EXPIRED_FORMATTED_QUERY = "DELETE FROM %s WHERE expireAt < ?";
public static final String REFRESH_FORMATTED_QUERY = "UPDATE %s SET expireAt = ? WHERE lock_key = ? AND token = ?";

Best Regards,
Ciprian

from distributed-lock.

alturkovic avatar alturkovic commented on June 23, 2024

@cipianpascu that was the first version of the queries. The issue is that INSERT INTO %s gets resolved into INSERT INTO lock and lock is a keyword in MySQL so it has to be escaped.
The current issue is that different databases escape keywords differently. So ` (backtick escape) is breaking PSQL syntax.

from distributed-lock.

cipianpascu avatar cipianpascu commented on June 23, 2024

Oh, I didn't know. But that is a small/corner case. No one will use the name 'lock' in production for a table. I propose to change the default to something else. For example 'tbl_lock' or 'table_lock' or anything else that is not interfering with the sql sintax.

from distributed-lock.

alturkovic avatar alturkovic commented on June 23, 2024

Should be fixed in 1.5.0, I decided to change the default table name as suggested to avoid further complications

from distributed-lock.

cipianpascu avatar cipianpascu commented on June 23, 2024

not yet. sadly I get ORA-00933: SQL command not properly ended in this moment

from distributed-lock.

alturkovic avatar alturkovic commented on June 23, 2024

It seems like it might be due to the semicolon at the end? I released a new fix version, could you try with that one? (1.5.1)

from distributed-lock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.