是否可以将mysql
命令LOAD DATA INFILE
用作PreparedStatement
?因为java似乎将?
占位符解释为文件名本身。
Statement st = con.prepareStatement("LOAD DATA LOCAL INFILE '?'...");
for (file : files) {
st.setString(1, file.getAbsolutePath());
st.addBatch();
}
st.executeBatch();
结果:
java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.41.jar:5.1.41]