SQL query in java with single quote

后端 未结 2 1484
梦毁少年i
梦毁少年i 2021-01-07 09:02

I have a query that I want run in java:

SELECT md5(CONCAT(md5(\'{clear password}\') , \'{salt}\'));

Its for my application to connect and u

2条回答
  •  孤独总比滥情好
    2021-01-07 10:02

    Example of prepared queries:

    /*
     * Some code
     */
    String strSQL = "select md5(concat(md5(?),?))"
    try(PreparedStatement ps = conn.prepareStatement(strSQL)) {
        ps.setString(1, password);
        ps.setString(2, pwdSalt);
        try(ResultSet rs = ps.executeQuery()) {
            rs.first();
            // Do whatever you need to do
        } catch(SQLException e) {
            // ...
        }
    } catch(SQLException e) {
        // ...
    }
    
    /*
     * More code
     */
    

提交回复
热议问题