Java – is JDBC secure?
•
Java
I am a novice in JDBC. The new project requires me to use JDBC What I want to know is,
Is JDBC secure?
How to prevent "MySQL injection" problems?
What security issues should you pay attention to when using JDBC?
And how to ensure, I mean, optimize security to prevent hackers from invading the database?
Edit:
I tried Google, if I Google:
"PHP MySQL security problem" = > it gives a lot of results
If I Google:
"JDBC MySQL security problem" = > almost no relevant pages can be seen
Does this mean that using JDBC is safe? Don't worry about being hacked?
Solution
Use prepared statements For a hypothetical login, you can use this, for example:
PreparedStatement stmt = conn.prepareStatement("SELECT * FROM member WHERE member_username = ? AND member_password = ?"); stmt.setString(1,username); stmt.setString(2,password); stmt.execute(); ResultSet rs = stmt.getResultSet(); // ...
This will completely protect you from SQL injection vulnerabilities
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码