I need to get a movie from a PostgreSQL database that matches the given name and release date. title is the character (75), and releaseDate is the date. I have this code:
String query = "SELECT * FROM \"Movie\" WHERE title = ? AND \"releaseDate\" = ?)";
Connection conn = connectionManager.getConnection();
PreparedStatement stmt = conn.prepareStatement(query);
java.sql.Date date = new java.sql.Date(releaseDate.getTime());
stmt.setString(1, title);
stmt.setDate(2, date);
ResultSet result = stmt.executeQuery();
but it does not work because releaseDate is not suitable if needed. Query SELECT * FROM "Movie" WHERE title = A_MOVIE AND "releaseDate"= A_DATE works fine in shell using psql
source
share