我目前在向数据库表写入有关 java 的一些信息时遇到问题。我不断得到
java.sql.SQLException:索引处缺少 IN 或 OUT 参数:: 1
请注意,该表已经创建并存在。
public static void includeToDB(File file, String email) throws Exception{
Connection connection = null;
PreparedStatement statement = null;
ResultSet resSet = null;
Date now = new Date();
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection(CONNECTION_STRING, USERNAME, PASSWORD);
String sql = "INSERT INTO T_EQ_STATEMENT_FILE_TRANS_LOG"
+ "(SENTDATE, FILENAME, EMAIL) " + "VALUES "
+ "("+ getCurrentTimeStamp() + "," + file.getName() + "," + email + ")";
/* "INSERT INTO CAMEL.T_EQ_STATEMENT_FILE_TRANS_LOG" +
" VALUES (" +
now + "," +
file.getName() + "," +
email + ");";
*/
statement = connection.prepareStatement(sql);
ResultSet resultSet = statement.executeQuery();
if(resultSet.next()) {
System.out.println("[DB_Handler] Information about sent file has been written to the DB... ");
} else {
System.out.println("[DB_Handler] Something went wrong, and writing the info has failed...");
}
} catch (SQLException e) {
logger.error(EQSFT_ERROR_TYPE.SQL_EXCEPTION.getErrorToPrint(), e);
logger.error("Messgage: " + e.getMessage());
logger.error("Error code: " + e.getErrorCode());
logger.error("SQL state: " + e.getSQLState());
} catch (Exception e) {
logger.error(EQSFT_ERROR_TYPE.UNKNOWN_EXCEPTION.getErrorToPrint(), e);
} finally {
if (statement != null) {
statement.close();
}
if (connection != null) {
connection.close();
}
}
}