Listify/Lambdas/Lists/SearchHistory/src/SearchHistoryGetter.java
NMerz 8653b9a035 Try storing serialized search object
Does not seem to be the best solution (https://stackoverflow.com/questions/17662236/java-write-object-to-mysql-each-field-or-serialized-byte-array)  and does not entirely work, but saving it for posterity because there are some interesting changes here
2020-11-14 11:40:42 -05:00

31 lines
1.1 KiB
Java

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
public class SearchHistoryGetter implements CallHandler {
private Connection connection;
private String cognitoID;
public SearchHistoryGetter(Connection connection, String cognitoID) {
this.connection = connection;
this.cognitoID = cognitoID;
}
final private String SELECT_HISTORY = "SELECT * from SearchHistory WHERE userID = ?;";
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
PreparedStatement select_history = connection.prepareStatement(SELECT_HISTORY);
select_history.setString(1, cognitoID);
System.out.println(select_history);
ResultSet searchHistory = select_history.executeQuery();
if (!searchHistory.first()) {
return new SearchHistory();
}
System.out.println(new SearchHistory(searchHistory));
return new SearchHistory(searchHistory);
}
}