所以我试图从PostgreSQL数据库中提取信息.以下是提取数据的方法:
public ResultSet dashboardQuerySurveyWithSelectedActions(String startDate,
String endDate, String agents) throws SQLException {
Connection connection = super.getNewConnection();
Statement statement = connection.createStatement();
String query = String.format("SELECT surveys_nps_rating, survey_agent_name, surveys_stream_item_key "
+ "FROM public.surveys "
+ "WHERE surveys_response_date BETWEEN %s AND %s"
+ "AND survey_agent_name IN %s", startDate, endDate, agents);
ResultSet resultSet = statement.executeQuery(query);
connection.close();
return resultSet;
}
Run Code Online (Sandbox Code Playgroud)
以下是我调用此方法时得到的错误:
('Honorine') - Parameter for Agent
2017-12-19 18:30:00 UTC - Start Date
2017-12-21 18:29:59 UTC - End Date
org.postgresql.util.PSQLException: ERROR: syntax error at or near …Run Code Online (Sandbox Code Playgroud)