正如评论中提到的,您应该删除?中的引号。
另外,在中
rs.getString(i),
i应为正。从1开始循环计数。
总结一下:
public ArrayList<String> findPath(String roomName) throws SQLException, IOException, InstantiationException, IllegalAccessException, ClassNotFoundException{ ArrayList<String> path = new ArrayList<String>(); connection = getConnection(); String queryPattern = "SELECt Livello_1, Livello_2, Livello_3, Livello_4 FROM Camera WHERe Camera.Nome = ?"; PreparedStatement queryStatement = connection.prepareStatement(queryPattern); queryStatement.setString(1, roomName); ResultSet rs = queryStatement.executeQuery(); if(rs.next()) { for(int i = 1; i < 4; i++) { path.add(rs.getString(i)); } } return path;}


