Skip to content

preventing sql injections #329

Answered by isoos
I-m-good-man asked this question in Q&A
May 2, 2024 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

@I-m-good-man: SQL injection happens when you are building a query string that includes the parameters inlined. If you want to do that, nobody can prevent it, however, it you are using the query method with the parameters, these values will not be inlined, instead sent as a separate part of the query. It prevents injection attacks, and also optimizes the query execution, as it spares the server a bit of time with a more efficient protocol.

There are multiple ways to specify parameter locations inside the query, you can see examples using @name or $2, but also ? could be used (each with different Sql initializer). The parameters object should be a Map for named parameters or List for index…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@I-m-good-man
Comment options

@isoos
Comment options

@I-m-good-man
Comment options

@isoos
Comment options

@I-m-good-man
Comment options

Answer selected by I-m-good-man
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants