Skip to content

Refactored to use parameterized SQL APIs#16

Open
pixeebot[bot] wants to merge 1 commit intomainfrom
pixeebot/drip-2025-08-10-pixee-java/sql-parameterizer
Open

Refactored to use parameterized SQL APIs#16
pixeebot[bot] wants to merge 1 commit intomainfrom
pixeebot/drip-2025-08-10-pixee-java/sql-parameterizer

Conversation

@pixeebot
Copy link
Copy Markdown

@pixeebot pixeebot bot commented Aug 10, 2025

This change refactors SQL statements to be parameterized, rather than built by hand.

Without parameterization, developers must remember to escape inputs using the rules for that database. It's usually buggy, at the least -- and sometimes vulnerable.

Our changes look something like this:

- Statement stmt = connection.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE name = '" + user + "'");
+ PreparedStatement stmt = connection.prepareStatement("SELECT * FROM users WHERE name = ?");
+ stmt.setString(1, user);
+ ResultSet rs = stmt.executeQuery();
More reading

🧚🤖 Powered by Pixeebot

Feedback | Community | Docs | Codemod ID: pixee:java/sql-parameterizer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants