public boolean checkOut(Book b, Timestamp startTime, int cardNumber, int idNumber) throws Exception {
		
		if(b == null || b.getCurrentQuantity() == 0){
			return false;
		}
		
		Connection connect = null;
		Statement statement = null;
		ResultSet resultSet = null;
		PreparedStatement preparedStatement = null;
		
		try {
			
			// First connect to the database
			connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/librarysystem?user=admin&password=123456");
			statement = connect.createStatement();
			
			resultSet = statement.executeQuery("SELECT maxReservation FROM BookType WHERE typeName = '" + b.getTypeName() + "'");
			
			// Get the first result (max number of days for the rental) of the query
			if(resultSet.next()){
				
				int reserveLength = resultSet.getInt("maxReservation");
				
				long oneDay = 1 * 24 * 60 * 60 * 1000;
				
				// Calculate the return date of the book rental
				Timestamp endTime = new Timestamp(startTime.getTime() + reserveLength * oneDay);
				
				preparedStatement = connect.prepareStatement("INSERT INTO CheckOut " + 
				"(isbn, start, end, cardNumber, idNumber) " + "VALUES (?, ?, ?, ?, ?)");
				
				preparedStatement.setLong(1, b.getIsbn());
				preparedStatement.setTimestamp(2, startTime);
				preparedStatement.setTimestamp(3, endTime);
				preparedStatement.setInt(4, cardNumber);
				preparedStatement.setInt(5, idNumber);
				
				// Store the checkout transaction in the database
				preparedStatement.executeUpdate();
				
		 		// Decrement the current quantity by 1
				preparedStatement = connect.prepareStatement("UPDATE Book " + 
				"SET currentQuantity = currentQuantity - 1 " + 
				"WHERE isbn = ?");
						
				preparedStatement.setLong(1, b.getIsbn());
				preparedStatement.executeUpdate();
				
				return true;
			}
			
			return false;
			
		} catch (Exception e) {
			System.out.println(e.getMessage());
			throw e;
		}
		
			finally
			{
				try {

					if(connect != null){
					connect.close();
					}
					
					if(statement != null){
					statement.close();
					}
					
					if(resultSet != null){
					resultSet.close();
					}
					
				} catch (Exception e) {	
					
				}
			}
	}