The documentation for Connector/J says that it can easily convert a MySQL INT to a Java String type. (That is, mapping from a result set to a Java type.)
But does this work the other way around? In other words, can you use a Java String in a prepared statement where MySQL expects an INT? Is this considered good/bad practice?
# pseudo-code
table EMPLOYEES
(
NAME VARCHAR(50)
EMPLOYEE_NO INT(11)
)
// Java code
PreparedStatement prepStmt =
con.prepareStatement("SELECT * from EMPLOYEES where EMPLOYEE_NO=?");
prepStmt.setString(1, str);
ResultSet rs = prepStmt.execute(); // ...