Skip to content

Commit

Permalink
Refactored to use parameterized SQL APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeebot[bot] authored Jul 31, 2024
1 parent 676d79e commit c984698
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.codemodder.codemods;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
Expand All @@ -12,10 +13,10 @@ public final class SQLTestMixed {
public ResultSet simpleIndirect() throws SQLException {
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
String input2 = scanner.nextLine();
String sql = "SELECT * FROM " + input + " where name='" + input2 + "'" ;
Statement stmt = conn.createStatement();
return stmt.executeQuery(sql);
String sql = "SELECT * FROM " + input + " where name=?" ;
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setString(1, scanner.nextLine());
return stmt.execute();
}

}

0 comments on commit c984698

Please sign in to comment.